1 回答
TA贡献1817条经验 获得超14个赞
ylim = (-100, 55)
它自己什么都不做,只是创建一个tuple被调用的ylim. 您需要做的是使用作为参数调用matplotlib.axes.Axes.set_ylim每个axes实例的方法,即ylim
fig, axs = plt.subplots(4, 5, figsize = (15,15))
ylim = (-100, 55)
k = 0
for i in range(4):
for j in range(5):
to_plot = real.loc[real['order_number'] == orderlist[k]]
axs[i,j].plot(to_plot['event_timestamp'], to_plot['altitude_in_meters'])
axs[i,j].plot(to_plot['event_timestamp'], to_plot['RASTERVALU'])
axs[i,j].set_ylim(ylim)
k+=1
如果您不希望绘制绘图之间的 y 刻度标签(因为所有绘图的 y 轴都相同),您也可以这样做
fig, axs = plt.subplots(4, 5, sharey=True, figsize = (15,15))
axs[0,0].set_ylim([-100, 55])
k = 0
for i in range(4):
for j in range(5):
to_plot = real.loc[real['order_number'] == orderlist[k]]
axs[i,j].plot(to_plot['event_timestamp'], to_plot['altitude_in_meters'])
axs[i,j].plot(to_plot['event_timestamp'], to_plot['RASTERVALU'])
k+=1
添加回答
举报