Plot a horizontal line using matplotlib

后端 未结 7 1365
旧时难觅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:13

    A nice and easy way for those people who always forget the command axhline is the following

    plt.plot(x, [y]*len(x))
    

    In your case xs = x and y = 40. If len(x) is large, then this becomes inefficient and you should really use axhline.

提交回复
热议问题