Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: N. Volbers <mithrandir42@we...>  20050912 19:51:08

Hello list, I have just figured out how to use transformations for the 'Text' object from the class library to add a text to the graph (well actually this applies to any Artist object). If the coordinates are given as absolute _screen_ coordinates (very unlikely...), we use: t = Text(x=x, y=y, text=text) axes.texts.append(t) If however the coordinates are given as _data_ coordinates x,y then we use: t = Text(x=x, y=y, text=text) t.set_transform(axes.transData) axes.texts.append(t) My question: Is there any transformation that would allow me to specify the coordinates as x,y tuple where (0,0) is bottom left and (1,1) is top right? In gnuplot this is known as the 'graph' coordinate system. Best regards, Niklas. 
From: N. Volbers <mithrandir42@we...>  20050912 19:51:08

Hello list, I have just figured out how to use transformations for the 'Text' object from the class library to add a text to the graph (well actually this applies to any Artist object). If the coordinates are given as absolute _screen_ coordinates (very unlikely...), we use: t = Text(x=x, y=y, text=text) axes.texts.append(t) If however the coordinates are given as _data_ coordinates x,y then we use: t = Text(x=x, y=y, text=text) t.set_transform(axes.transData) axes.texts.append(t) My question: Is there any transformation that would allow me to specify the coordinates as x,y tuple where (0,0) is bottom left and (1,1) is top right? In gnuplot this is known as the 'graph' coordinate system. Best regards, Niklas. 
From: Nicolas <nico_75_0@ya...>  20070201 18:17:15
Attachments:
Message as HTML

Hello, I tried to use some affine transformations, but it didn't match to get it works. I use matplotlib 0.87.5 with python 2.4.3 and Numeric 24.2 on winXP. I tried for example : plot([1,0,1],[0,1,0], transform = matplotlib.transforms.Affine(0,1,1,0,0,0)) Then I got : Traceback (most recent call last): File "<input>", line 1, in ? File "C:\Python24\lib\sitepackages\matplotlib\pylab.py", line 2019, in plot ret = gca().plot(*args, **kwargs) File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 2124, in plot self.add_line(line) File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 879, in add_line xys = self._get_verts_in_data_coords( File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 934, in _get_verts_in_data_coords xys = trans.numerix_xy(asarray(xys)) ValueError: Domain error on Transformation::numerix_xy >>> plot([1,0,1],[0,1,0], transform = matplotlib.transforms.Affine(1,0,0,1,0,0)) Traceback (most recent call last): File "<input>", line 1, in ? File "C:\Python24\lib\sitepackages\matplotlib\pylab.py", line 2019, in plot ret = gca().plot(*args, **kwargs) File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 2124, in plot self.add_line(line) File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 879, in add_line xys = self._get_verts_in_data_coords( File "C:\Python24\lib\sitepackages\matplotlib\axes.py", line 934, in _get_verts_in_data_coords xys = trans.numerix_xy(asarray(xys)) ValueError: Domain error on Transformation::numerix_xy Thanks a lot, Nicolas  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses. 
From: John Hunter <jdh2358@gm...>  20070205 19:33:31

On 2/1/07, Nicolas <nico_75_0@...> wrote: > I tried to use some affine transformations, but it didn't match to get it > works. > I use matplotlib 0.87.5 with python 2.4.3 and Numeric 24.2 on winXP. > > I tried for example : > plot([1,0,1],[0,1,0], transform = matplotlib.transforms.Affine(0,1,1,0,0,0)) You cannot pass scalars to the Affine constructor  matplotlib uses value reference semantics in the transform, as explained at http://matplotlib.sf.net/matplotlib.transforms.html and so you need to construct your transformation like so: import matplotlib.transforms as t def make_affine(a,b,c,d,tx,ty): return t.Affine(*[t.Value(val) for val in (a,b,c,d,tx,ty)]) a = make_affine(0,1,1,0,0,0) >>> print a.xy_tup((1,1)) (1.0, 1.0) >>> print a.xy_tup((1,1)) (1.0, 1.0) Note there was a bug in older versions of mpl in the affine class that was fixed, specifically in the sign of b and c. I am not sure which version that was off the top of my head, so if you see any problems consider upgrading. 
From: John Hunter <jdh2358@gm...>  20070206 16:20:23

On 2/6/07, Nicolas <nico_75_0@...> wrote: > Thanks a lot for your reply. You're welcome. Please keep correspondence on the list so others an contribute and benefit. > I read this story of lazy value in the doc, but I didn't understand the link > with the the Affine function. All of the matplotlib transformations are by reference. We want to be able to do build the transform like so: a = someval t = Affine(a,b,c,d,e,f) and then later in the code do a.set(23) and have the transformation automatically updated. You can't do this if a is a scalar value (eg a float) so we have a custom class Value which stores a pointer to a float. When you do a = Value(23) t = Affine(a,b,c,d,e,f) and later do a.set(23) then t will be updated. We also support arithmetic on Values, so you can do z = Value(3) x = Value(2) t = Affine(z*x,b,c,d,e,f) and later if you do x.set(4) then the transform will be updated to have the value a=12 >From a user perspective, it means you need do do t = Affine(Value(a), Value(b), .....) if a and b are floats. This is what the make_affine function that I posted does. > Additionnaly, I noticed that antialiasing doesn't seem to work anymore in > function pie with recent (ie. 0.87.5) version of matplotlib on WxAgg (?) Odd, I see that too. Haven't been able to pinpoint the problem yet... JDH 
From: John Hunter <jdh2358@gm...>  20070606 19:16:41

On 6/6/07, Nicolas <nico_75_0@...> wrote: > Unfortunately, I didn't use instantiated Polygon items myself, so for now I > can't figure which part of my code produces indirectly such empty > Polygons... > > May it be however possible to modify a little matplotlib code, so as to > assure the compatibility with the previous existing versions of matplotlib ? > Something like : I don't have a problem with this, but it just makes it easier for latent bugs in your code to remain hidden. Should we raise in the Polygon constructor is you pass in an empty list of vertices? Of course, you can always set xy directly, so this won't catch all the errors unless we use properties or traits. JDH 
From: Nicolas <nico_75_0@ya...>  20070606 20:14:58
Attachments:
Message as HTML

I can't figure why Polygons are used even when I simply draw lines. But I know at least why I use empty list of vertices. ;) In fact, I use matplotlib for a dynamic geometry software (something like GeoGebra), and systematic use of highlevel functions of matplotlib would be to slow for that purpose. And yet, I didn't want to use too lowlevel functions, like the renderer's ones, for I didn't want to depend too much of a particular renderer. So, I created once a set of plots and fills for every object, and then I modified its attributes . I used to set its vertices to an empty list when I didn't want it to appear on the figure. I suppose now I'd better use instead something like. my_plot._visible = False Nevertheless, I think empty vertices should be supported here (or not supported at all for all renderers  for in 0.90.1 it still works with tkagg for example) Nicolas On 6/6/07, John Hunter <jdh2358@...> wrote: > > On 6/6/07, Nicolas <nico_75_0@...> wrote: > > > Unfortunately, I didn't use instantiated Polygon items myself, so for > now I > > can't figure which part of my code produces indirectly such empty > > Polygons... > > > > May it be however possible to modify a little matplotlib code, so as to > > assure the compatibility with the previous existing versions of > matplotlib ? > > Something like : > > I don't have a problem with this, but it just makes it easier for > latent bugs in your code to remain hidden. Should we raise in the > Polygon constructor is you pass in an empty list of vertices? Of > course, you can always set xy directly, so this won't catch all the > errors unless we use properties or traits. > > JDH > 
From: John Hunter <jdhunter@ac...>  20050912 20:29:17

>>>>> "N" == N Volbers <mithrandir42@...> writes: N> Hello list, I have just figured out how to use transformations N> for the 'Text' object from the class library to add a text to N> the graph (well actually this applies to any Artist object). N> If the coordinates are given as absolute _screen_ coordinates N> (very unlikely...), we use: N> t = Text(x=x, y=y, text=text) N> axes.texts.append(t) N> If however the coordinates are given as _data_ coordinates x,y N> then we use: N> t = Text(x=x, y=y, text=text) N> t.set_transform(axes.transData) N> ax.texts.append(t) You can also pass the transform as a kwarg t = Text(x=x, y=y, text=text, transform=axes.transData) ax.texts.append(t) N> My question: Is there any transformation that would allow me to N> specify the coordinates as x,y tuple where (0,0) is bottom left N> and (1,1) is top right? In gnuplot this is known as the 'graph' N> coordinate system. There are four builtin transforms that you should be aware of; below ax is an Axes instance and fig is a Figure instance matplotlib.transforms.identity_transform() # display coords ax.transData # data coords ax.transAxes # 0,0 is bottom,left of axes and 1,1 is top,right fig.transFigure # 0,0 is bottom,left of figure and 1,1 is top,right There is nothing wrong with instantiating Text instances yourself and adding them to the figure or axes manually as you did, but both the Axes and Figure have helper methods "text" which define a default transformation that can be overridden So t = Text(x=x, y=y, text=text) t.set_transform(axes.transAxes) ax.texts.append(t) is equivalent to ax.text(x, y, text, transform=ax.transAxes) The default transform for ax.text is ax.transData and the default transform for fig.text is fig.transFigure. Of course, you can define more general transformations, eg matplotlib.transforms.Affine, but the four listed above arise in a lot of applications. If you have time and inclination to write a transformations tutorial for the wiki, that would be great. Thanks, JDH 
From: N. Volbers <mithrandir42@we...>  20050912 20:58:53

Hello John, > >There is nothing wrong with instantiating Text instances yourself and >adding them to the figure or axes manually as you did, but both the >Axes and Figure have helper methods "text" which define a default >transformation that can be overridden > >So > > t = Text(x=x, y=y, text=text) > t.set_transform(axes.transAxes) > ax.texts.append(t) > >is equivalent to > > ax.text(x, y, text, transform=ax.transAxes) > > > ax.text was my starting point to understand the usage of Text(). For my application I need a very detailed control of the objects I create, this is why I prefer the manual approach. > >If you have time and inclination to write a transformations tutorial >for the wiki, that would be great. > > > Not tonight, but I will! Thanks so much for your answer, Niklas. 
Sign up for the SourceForge newsletter:
No, thanks