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
添加回答
舉報