I want to plot a vertical line that spans the entire y axis located for example in the x=.25 position of the x axis, not the data axis.
According to this answer (which is apparently not entirely accurate) the axhline,axvline functions would draw a horizontal/vertical line in the axes coordinates, as shown in:
The method axhline and axvline are used to draw lines at the axes coordinate
But this does not seem to work. The axhline docs say:
y position in data coordinates of the horizontal line.
and sure enough, the code given in the answer above displays:
Compare with the old plot shown in the mentioned answer (code below):
Did this change recently or am I missing something very obvious? If it did change, how would I draw a line in the axes coordinate now?
I'm using Python 3.7.3 and matplotlib 3.1.0.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 100)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)
ax.axhline(y=0.5, xmin=0.0, xmax=1.0, color='r')
ax.hlines(y=0.6, xmin=0.0, xmax=1.0, color='b')
plt.show()


minmaxparameters, no?y=0.5in data- nor in axes coordinates. So I think one can assume it to be generated by a code that is not shown in the answer. But if you replace the wrong image with the one you get with that code, the answer is correct, rigth? It might make sense to just edit that answer.