Plot a horizontal line using matplotlib

后端 未结 7 1357
旧时难觅i
旧时难觅i 2020-11-27 11:39

I have used spline interpolation to smooth a time series and would also like to add a horizontal line to the plot. But there seems to be an issue that is out of my grips. An

7条回答
  •  一生所求
    2020-11-27 12:06

    In addition to the most upvoted answer here, one can also chain axhline after calling plot on a pandas's DataFrame.

    import pandas as pd
    
    (pd.DataFrame([1, 2, 3])
       .plot(kind='bar', color='orange')
       .axhline(y=1.5));
    

提交回复
热议问题