|
From: <kc1...@ya...> - 2007-03-07 17:40:54
|
Thanks for the answer, John and Jouni.=0A=0AOkay, Line2D works. However, i= t appears to work in point (or is it pixels?) only. It doesn't accept xyco= ords=3D"figure fraction" as an option. How can I specify xy as a fraction = of the figure size?=0A=0AI read the transform cookbook cited by Jouni. I a= m afraid I am lost what that does....=0A=0ARegards,=0A=0A> -----Original Me= ssage-----=0A> From: mat...@li... =0A> [m= ailto:mat...@li...] On =0A> Behalf Of Joh= n Hunter=0A> Sent: Wednesday, March 07, 2007 6:48 AM=0A> To: matplotlib-use= rs...@li...=0A> Subject: Re: [Matplotlib-users] How to draw a = straight line?=0A> =0A> =0A> On 3/6/07, Jouni K. Sepp=E4nen <jk...@ik...> wr= ote:=0A> > kc1...@ya... writes:=0A> > > How do I draw a = line going from point A to point B on a =0A> figure (not=0A> =0A> It probab= ly makes more sense not to use Axes.plot at all, =0A> since the line is not= associated with an Axes=0A> =0A> from matplotlib.lines import Line2D=0A> f= rom pylab import figure, show, nx=0A> =0A> fig =3D figure()=0A> line =3D Li= ne2D([100,200,300,400,500], [100,400, 350, 200, 500],=0A> lin= ewidth=3D4, color=3D'green')=0A> fig.lines.append(line)=0A> show()=0A> =0A>= =0A> But this feature isn't used very much, and one thing that we =0A> are= not currently supporting (but should) is the zorder for =0A> Artists in th= e Figure. So if you have an Axes in your plot =0A> and you want the line t= o go over it, you'll need to do =0A> something like Jouni suggested so the = line will be drawn =0A> above the Axes.=0A> =0A> --------------------------= ------------------------------------=0A> -----------=0A> Take Surveys. Earn= Cash. Influence the Future of IT=0A> Join SourceForge.net's Techsay panel = and you'll get the =0A> chance to share your opinions on IT & business topi= cs through =0A> brief surveys-and earn cash =0A> http://www.techsay.com/def= ault.php?page=3Djoin.php&p=3Dsourceforge=0A&CID=3DDEVDEV=0A________________= _______________________________=0AMatplotlib-users mailing list Matplotlib-= us...@li...=0Ahttps://lists.sourceforge.net/lists/listinfo/= matplotlib-users=0A=0A =0A--=0AJohn Henry=0A=0A |
|
From: <kc1...@ya...> - 2007-03-07 17:59:58
|
Upon working with this a little further, I discover that it works only in f= ull-view screen mode. May be that's because xy is in pixel mode then? Whe= n I save it to a png file and then view it, the lines are wrong.=0A =0A--= =0AJohn Henry=0A=0A----- Original Message ----=0AFrom: "kc106_2005-matplotl= ib...@ya..." <kc1...@ya...>=0ATo: matplotlib-users@list= s.sourceforge.net=0ASent: Wednesday, March 7, 2007 9:40:45 AM=0ASubject: Re= : [Matplotlib-users] How to draw a straight line?=0A=0AThanks for the answe= r, John and Jouni.=0A=0AOkay, Line2D works. However, it appears to work in= point (or is it pixels?) only. It doesn't accept xycoords=3D"figure fract= ion" as an option. How can I specify xy as a fraction of the figure size?= =0A=0AI read the transform cookbook cited by Jouni. I am afraid I am lost = what that does....=0A=0ARegards,=0A=0A> -----Original Message-----=0A> From= : mat...@li... =0A> [mailto:matplotlib-us= ers...@li...] On =0A> Behalf Of John Hunter=0A> Sent: = Wednesday, March 07, 2007 6:48 AM=0A> To: mat...@li...= e.net=0A> Subject: Re: [Matplotlib-users] How to draw a straight line?=0A> = =0A> =0A> On 3/6/07, Jouni K. Sepp=E4nen <jk...@ik...> wrote:=0A> > kc106_20= 05-...@ya... writes:=0A> > > How do I draw a line going from poi= nt A to point B on a =0A> figure (not=0A> =0A> It probably makes more sense= not to use Axes.plot at all, =0A> since the line is not associated with an= Axes=0A> =0A> from matplotlib.lines import Line2D=0A> from pylab import fi= gure, show, nx=0A> =0A> fig =3D figure()=0A> line =3D Line2D([100,200,300,4= 00,500], [100,400, 350, 200, 500],=0A> linewidth=3D4, color= =3D'green')=0A> fig.lines.append(line)=0A> show()=0A> =0A> =0A> But this fe= ature isn't used very much, and one thing that we =0A> are not currently su= pporting (but should) is the zorder for =0A> Artists in the Figure. So if = you have an Axes in your plot =0A> and you want the line to go over it, you= 'll need to do =0A> something like Jouni suggested so the line will be draw= n =0A> above the Axes.=0A> =0A> -------------------------------------------= -------------------=0A> -----------=0A> Take Surveys. Earn Cash. Influence = the Future of IT=0A> Join SourceForge.net's Techsay panel and you'll get th= e =0A> chance to share your opinions on IT & business topics through =0A> b= rief surveys-and earn cash =0A> http://www.techsay.com/default.php?page=3Dj= oin.php&p=3Dsourceforge=0A&CID=3DDEVDEV=0A_________________________________= ______________=0AMatplotlib-users mailing list Mat...@li...= eforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/matplotlib-users= =0A=0A =0A--=0AJohn Henry=0A=0A=0A=0A=0A |
|
From: John H. <jd...@gm...> - 2007-03-07 18:11:38
|
On 3/7/07, kc1...@ya...
<kc1...@ya...> 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)
fig.lines.append(line)
show()
|
|
From: <kc1...@ya...> - 2007-03-07 18:53:10
|
Thanks, John. That works perfectly. Now I understand better what the tran= sform parameter is.=0A=0ARegards,=0A=0A> -----Original Message-----=0A> Fro= m: John Hunter [mailto:jd...@gm...] =0A> Sent: Wednesday, March 07, 2= 007 10:12 AM=0A> To: kc1...@ya...=0A> Cc: matplotlib-use= rs...@li...=0A> Subject: Re: [Matplotlib-users] How to draw a = straight line?=0A> =0A> =0A> On 3/7/07, kc1...@ya... =0A= > <kc1...@ya...> wrote:=0A> =0A> > Upon working with thi= s a little further, I discover that it =0A> works only =0A> > in full-view = screen mode. May be that's because xy is in =0A> pixel mode =0A> > then? = When I save it to a png file and then view it, the lines are =0A> > wrong.= =0A> =0A> The default coords in the example I posted are in pixels -- =0A> = when you save, you are probably using a different DPI (this =0A> is configu= rable) and so the lines have slightly different =0A> positions. You can us= e relative coords with the =0A> "transFigure" transform=0A> =0A> =0A> from = matplotlib.lines import Line2D=0A> from pylab import figure, show, nx=0A> = =0A> fig =3D figure()=0A> line =3D Line2D([0.1,0.2,0.3,0.4,0.5], [0.1,0.4, = 0.35, 0.2, 0.5],=0A> linewidth=3D4, color=3D'green', transfor= m=3Dfig.transFigure)=0A> fig.lines.append(line)=0A> show()=0A> =0A =0A--=0A= John Henry=0A=0A |