Reputation: 675
I would like to draw a static vertical line that is parallel to the y-axis and which is at the middle of the x-axis. This line should not move when one pan in the figure. My goal is to have this vertical line in the middle of the figure as a reference line. I will have some other figures which represent data that will depend on the x value which is at the middle of the x-axis.
Upvotes: 2
Views: 5588
Reputation: 44152
The coordinates of the endpoints of that line are (0.5, 0) and (0.5, 1) in axis coordinates:
from matplotlib.lines import Line2D
from matplotlib import pyplot
f=pyplot.figure()
a=f.add_subplot(111)
a.plot([3,1,4,1,5,9,2], color='k') # so you have some content
a.add_line(Line2D([0.5, 0.5], [0, 1], transform=a.transAxes,
linewidth=2, color='b'))
pyplot.show()
Upvotes: 4