概述
primitives 和 container的关系
matplotlib标准使用流程
fig = plt.figure()
ax = fig.add_subplot(2, 1, 1)
t = np.arange(0.0, 1.0, 0.01)
s = np.sin(2*np.pi*t)
line = ax.plot(t, s, color='darkgreen', lw=5)
基本元素 primitives
Line2D
设置Line2D的属性
plt.plot(x,y, linewidth=10, color='b');
line, = plt.plot(x, y, '*')
line.set_antialiased(False)
lines = plt.plot(x, y)
plt.setp(lines, color='g', linewidth=7);
如何绘制Lines
绘制直线line
方法一:用pyplot
plt.plot(x,y);
方法二:Line2D对象绘制
from matplotlib.lines import Line2D
fig = plt.figure()
ax = fig.add_subplot(111)
line = Line2D(x, y)
ax.add_line(line)
ax.set_xlim(min(x), max(x))
ax.set_ylim(min(y), max(y))
plt.show()
errorbar绘制误差折线图
plt.errorbar(x, y+3, yerr=yerr,
label='both limits (default)',
fmt='co--');
|