Python繪圖之——matplotlib顏色與線條
阿新 • • 發佈:2018-12-09
- 常用顏色: 八種內建預設顏色縮寫
b: blue
g: green
r: red
c: cyan
m: magenta
y: yellow
k: black
w: white
其他顏色表示方法:灰色陰影,html 十六進位制RGB 元組
- 簡單例子:繪製曲線
import matplotlib.pyplot as plt
plt.subplots(1, 1)
x= range(100)
y= [i**2 for i in x]
plt.plot(x, y, linewidth = '1', label = "test", color='y' , linestyle=':', marker='|')
plt.legend(loc='upper left')
plt.show()
結果: 3. 第二個參考網址給出的linestyle可選引數:
'-' solid line style
'--' dashed line style
'-.' dash-dot line style
':' dotted line style
4.第二個參考網址給出的marker可選引數:
'.' point marker
',' pixel marker
'o' circle marker
'v' triangle_down marker
'^' triangle_up marker
'<' triangle_left marker
'>' triangle_right marker
'1' tri_down marker
'2' tri_up marker
'3' tri_left marker
'4' tri_right marker
's' square marker
'p' pentagon marker
'*' star marker
'h' hexagon1 marker
'H' hexagon2 marker
'+' plus marker
'x' x marker
'D' diamond marker
'd' thin_diamond marker
'|' vline marker
'_' hline marker
4.