Vertical lines

Nils Wagner wrote:

    >> How can I add vertical/horizontal lines (x=constant, y=constant
    >> respectively) to an existing plot with matplotlib ?

    > I've always done something like:

    > plot(x,y) a=axis() plot(a[0:2],[50,50],'k')

    > for example, to get a line at y=50. If there's something
    > shorter I'm open to suggestions.

if you want to plot a line in data coordinates, you can use vline

  plot([0,1,2],[3,4,5])
  vlines([1], [4,5], hold=True)

See also vlines. This x and y location of this line will "move" with
the data when you pan and zoom.

If you want to plot a line in axes coords, us axvline, where x is in
data coords but y is now interpreted as a fraction of the axes width
and the x location will not move with pans and zooms. Thus if you
want a vertical bar at x=1 that ranges from the top to the bottom, do

  axvline(1) # ymin=0 (bottom) and ymax=1 (top) default

The x location moves with pan/zoom but the y data are fixed.

JDH