How to draw a straight line?

Thanks, John. That works perfectly. Now I understand better what the transform parameter is.



-----Original Message-----
From: John Hunter [mailto:jdh2358@…287…]
Sent: Wednesday, March 07, 2007 10:12 AM
To: kc106_2005-matplotlib@...9...
Subject: Re: [Matplotlib-users] How to draw a straight line?

On 3/7/07, kc106_2005-matplotlib@...9... > <kc106_2005-matplotlib@...9...> wrote:

> Upon working with this a little further, I discover that it
works only
> in full-view screen mode. May be that's because xy is in
pixel mode
> then? When I save it to a png file and then view it, the lines are
> wrong.

The default coords in the example I posted are in pixels --
when you save, you are probably using a different DPI (this
is configurable) and so the lines have slightly different
positions. You can use relative coords with the
"transFigure" transform

from matplotlib.lines import Line2D
from pylab import figure, show, nx

fig = figure()
line = Line2D([0.1,0.2,0.3,0.4,0.5], [0.1,0.4, 0.35, 0.2, 0.5],
              linewidth=4, color='green', transform=fig.transFigure)

John Henry