访问子批轴返回Pandas.DataFrame.plot()

2024-05-13 03:14:13 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有方法可以访问pandas.DataFrame.plot(subplots=True)返回的轴?我想给每个绘图赋予一个标题(并访问其他属性),但我当前的尝试只影响最后一个子图。在

svv[['Flow2 L/s','GWT','DOC mg/L', 'Hgtot ng/L', 'MeHg ng/L']].dropna().plot(subplots=True, figsize=(20, 20)) 
plt.legend(loc='best')
ax[0].set_title('title1') # Doesn't alter any of the plots
ax[1].set_title('title2') # Doesn't alter any of the plots
plt.title('5 plots') # Title appears above the last plot

我也尝试过使用matplotlib.subplots()单独创建子图,但这导致共享的x轴不再仅仅是在所有被绘制的Series的交集处。在


Tags: ofthe方法trueplottitleanyplt
1条回答
网友
1楼 · 发布于 2024-05-13 03:14:13

{1>调用的结果是返回的。您可以将其存储在变量中:

ax = svv[['Flow2 L/s','GWT','DOC mg/L', 'Hgtot ng/L', 'MeHg ng/L']].dropna().plot(subplots=True, figsize=(20, 20))

相关问题 更多 >