下面的代码给了我更深的图像。如何在iPython笔记本中重复使用绘图布局?
flowRates=[2,5,10,20,50]
flowRateTol=0.2
#sets the limits for the plot
xRange=(0,700)
yRange=(0,70)
ax=axes()
ax.set_xlabel('Time (s)')
#ax.set_ylabel('Reaction Force (lbf)')
ax.legend(loc=0)
#set up the second axis
ax.twinx()
ax.set_ylabel('10s Average Flow Rate')
ax.set_xlim(xRange)
ax.set_ylim(yRange)
#shade the acceptable tolerance bands
for flowRate in flowRates:
rectX=[0,xRange[1],xRange[1],0]
rectY=[ flowRate*(1-flowRateTol),
flowRate*(1-flowRateTol),
flowRate*(1+flowRateTol),
flowRate*(1+flowRateTol)]
ax.fill(rectX,rectY,'b', alpha=0.2, edgecolor='r')
但是我想在我的下IPython的细胞做的是真正在图形上绘制数据。我正在使用的代码(失败的代码是)只是打电话给ax.plot()
,但我无法得到一张图显示我的数据。
有什么想法?我的目标是有一个worflow(我会介绍)这样的事情:
- 看看我如何导入我的数据!
- 这是我如何设置我的图! (显示底图)
- 这就是我如何绘制我的所有数据! (用数据显示底图)
- 这就是我如何过滤我的数据! (做一些奇特的过滤)
- 这就是过滤的数据看起来像! (在相同的底图上显示新数据)
您需要'plt.draw()'或'ax.figure.canvas.draw()'来重新渲染坐标轴。您应该将第二个轴捕获为'ax2 = ax.twinx()'。 – tacaswell