如何在iPython笔记本中重复使用打印布局>;?
下面的代码给了我下面更进一步的图像如何在iPython笔记本中重复使用打印布局>;?,python,matplotlib,ipython,ipython-notebook,Python,Matplotlib,Ipython,Ipython Notebook,下面的代码给了我下面更进一步的图像 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
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()
,但我无法获得显示数据的图形
有什么想法吗?我的目标是创建一个类似以下内容的工作流(我将演示):
我建议将不同的想法打包到函数中。例如
data=None
忽略错误,而不绘制任何内容
像这样拆分代码的好处在于,只要担心输入和输出,就可以很容易地对一个函数进行更改。例如,要进行筛选,您可以向
绘图
函数添加筛选参数,或创建以相同方式绘图的新筛选数据 您需要一个plt.draw()
或ax.figure.canvas.draw()
来重新渲染轴。您应该将第二个轴捕获为ax2=ax.twinx()
。感觉上我遇到的是结构问题,而不是编程问题。你的解决方案很有效。非常感谢。