简体   繁体   中英

When plotting specific column of a pandas df, jupyter notebook only shows 1 graph per cell. How can I show multiple graphs separately

%matplotlib inline

matplotlib.rcParams['figure.figsize']= (20, 10)
df_1['col1'].plot(kind='bar')
df_2['col1'].plot(kind='bar')

In above code, only the first graph shows up in jupyter notebook.

But if I am plotting entire df then multiple graphs will show in jupyter notebook. eg:

df_1.plot(kind='bar')
df_2.plot(kind='bar')

I would like to see 2 different figures in the output.

Use axes handles:

ax = df_1.plot(kind='bar')
_ = df_2.plot(kind='bar', ax=ax)

Example:

ax = df_1.plot(kind='bar', alpha = .4)
_ = df_2.plot(kind='bar', ax=ax, color='green', alpha = .4)

在此处输入图片说明

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