step 1. 引用库
import matplotlib.pyplot as pyplot #plot figure
step 2. 准备曲线图显示界面
pyplot.ion() #Used interactive mode
step 3. 创建图形(fig --- figure)
fig = pyplot.figure()
fig.canvas.manager.set_window_title("Python test by 英布之剑(QQ:553915902)")
step 4.初始化坐标轴和曲线(ax --- axis)
ax = fig.add_subplot(1, 1, 1) # n_rows, n_cols, index
x = num.arange(0, 10) # create a sequential array with start, stop, [step]
y = num.zeros(10) # create an all zero array with length
line, = ax.plot(x, y) # 初始化曲线
* 这里用到的numpy库,请在使用前加入以下内容
import numpy as num
step 5.设置坐标轴启始值
ax.set_ylim(bottom=0)
step 5. 标题设置(包含如何让标题显示中文)
pyplot.rcParams['font.sans-serif']=[u'SimHei'] #for标题中文显示
pyplot.rcParams['axes.unicode_minus']=False #同上
pyplot.title("Stock Code")
step 6. 刷新图形
fig.canvas.draw()
pyplot.pause(0.01)
step 7. 清除已有曲线
ax.clear()