Pandas: Bar-Plot with two bars and two y-axis

后端 未结 4 985
清酒与你
清酒与你 2020-11-30 23:21

I have a DataFrame looking like this:

     amount     price
age
A     40929   4066443
B     93904   9611272
C    188349  19360005
D    248438  24335536
E             


        
4条回答
  •  鱼传尺愫
    2020-11-30 23:32

    As mentioned by InLaw you should use secondary_y = 'amount'

    To add to his answer here is how to set the ylabels for the two axis:

    df.plot.bar(figsize=(15,5), secondary_y= 'amount')
    
    ax1, ax2 = plt.gcf().get_axes() # gets the current figure and then the axes
    
    ax1.set_ylabel('price')
    
    ax2.set_ylabel('amount')
    

提交回复
热议问题