简体   繁体   中英

How to arrange df.plot.line() into subplots

I have several DF with only numerical columns. I'm using df.plot.line() to see the data and it works fine as it plots graphs separately.

Now I'm trying a way to arrange those graphs into a subplot but I can't find a way.

here is an example:

df_km_cumsum.plot.line(figsize=[20,15],legend=False)

gives this plot

df_daytot_km.plot.line(figsize=[20,15],legend=False)

gives this other plot

Now I'd like to put them inside a 2x1 figure to make them see together.

Any help is kindly accepted. Thank you

plt.subplot(2, 1, 1)
df_km_cumsum.plot.line(figsize=[20,15],legend=False)

plt.subplot(2, 1, 2)
df_daytot_km.plot.line(figsize=[20,15],legend=False) 

Thanks to @tmdavision, here is the final solution:

fig, (ax1, ax2) = plt.subplots(2,figsize=[20,15])

df_km_cumsum.plot.line(legend=False, ax=ax1)

df_dayavg_km.plot.line(legend=False, ax=ax2)

plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM