参考:http://matplotlib.org/api/pyplot_api.html
画图功能总结(2):http://blog.csdn.net/mmc2015/article/details/48222611
1、matplotlib.pyplot.plot(*args, **kwargs),最简单的沿坐标轴划线函数:
下面四种格式都合法:
plot(x, y) # plot x and y using default line style and color plot(x, y, 'bo') # plot x and y using blue circle markers plot(y) # plot y using x as index array 0..N-1 plot(y, 'r+') # ditto, but with red plusses
<pre name="code" class="python">import numpy as np
import matplotlib.pyplot as plt
x1=np.arange(0,5,0.1)
y1=np.sin(x1)
x2=np.linspace(1,10,20,True)
y2=np.cos(x2)
plt.plot(x1,y1,'b^')
也可以同时画一组图:
plt.plot(x1, y1, 'go', x2, y2, 'r-')
如果颜色不显示指出,则默认循环使用不同的颜色,支持的颜色有:
character | color |
---|---|
‘b’ | blue |
‘g’ | green |
‘r’ | red |
‘c’ | cyan |
‘m’ | magenta |
‘y’ | yellow |
‘k’ | black |
‘w’ | white |
character | description |
---|---|
'-' | solid line style |
'--' | dashed line style |
'-.' | dash-dot line style |
':' | dotted line style |
'.' | 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' |