Python making combined bar and line plot with secondary y-axis

后端 未结 2 1839
暗喜
暗喜 2020-12-02 01:05

I am trying to plot some csv data. I would like to plot some csv data. The data is shown below. I\'m trying to plot columns 1-11 as a bar plot and column 12 as a line. I

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 01:39

    You just need to plot them on the same axis

    ax = df.iloc[:,[0,1,2,3,4,5,6,7,8,9,10]].plot(kind='bar')
    df.iloc[:,12].plot(linestyle='-', marker='o', ax = ax)
    
    ax.set_xticklabels(df.DateTime, rotation=40) #set the x-ticks to datetime column and rotate
    

    is the code I used to plot both the graphs on same plot

提交回复
热议问题