Plot a chart with two y-axes in pyplot

Viewed 133

I want to plot two y-axes in a chart. So far I can plot two y-axes but the y-axes at right hand side but how to change the right y-axes at the same level of the zero?

dict_one = {'date': [pd.Timestamp('20150720'),pd.Timestamp('20160720'),pd.Timestamp('20170720'),pd.Timestamp('20180720'),pd.Timestamp('20190720'),pd.Timestamp('20200720')],
            'BKNG': [15.22, 6.36, 5.05, 5, 9.3641, -3],
            'MCD' : [25.22, 11.36, 7.05, 9, 8.3641, -6],
            'YUM' : [52.22, 21.36, 25.05, 26, 21.3641, -1000]
    
}

df = pd.DataFrame(dict_one)
df['date'] = df['date'].dt.year
df.set_index('date',inplace=True)

df.plot(figsize= (20,8), kind='bar',secondary_y='YUM')

output

0 Answers
Related