0

I tried to plot barchart and line chart on the same plot. But the linechart is not showing correctly(it seemed like it is starting at month 10). Please advise.

ax = df.groupby('month')['Tavg'].mean().plot.line()

enter image description here

ax = df_train.groupby('month').wnvpresent.sum().plot.bar()
ax1 = ax.twinx()
df.groupby('month')['Tavg'].mean().plot.line(ax=ax1);

enter image description here

SoraHeart
  • 338
  • 3
  • 9
  • barplots use categorical axes, line plots use numerical axes. you could probably force your line plot to be categorical. the matplotlib docs have a whole section dedicated to categorical axes – Paul H Oct 18 '21 at 14:59

0 Answers0