Home > Software design >  How to add horizontal line to a pandas df plot?
How to add horizontal line to a pandas df plot?

Time:10-29

I want to draw a line on y=0. However, I am not sure how to do that using pandas built-in charting. df.mean(axis=1).plot() I am running this and that is the result.

Time series plot

CodePudding user response:

Catch the ax instance returned by plot, and you can use axhline:

ax = df.mean(axis=1).plot()
ax.axhline(0, c='r')

Output:

enter image description here

  • Related