I would like to draw a horizontal line with matplotlib's plt.axhline()
function, but I want the horizontal line to stop at the absolute value of 5 on the x-axis. How do I set xmax
in plt.axhline()
to stop at 5?
plt.figure()
plt.plot(np.arange(-60, 60, 20), np.arange(0, 1.2, 0.2))
plt.axhline(y = 0.5, xmax = 5, c= 'r')