transformations

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 “”, line 1, in ?
File “C:\Python24\lib\site-packages\matplotlib\pylab.py”, line 2019, in plot
ret = gca().plot(*args, **kwargs)
File “C:\Python24\lib\site-packages\matplotlib\axes.py”, line 2124, in plot
self.add_line(line)
File “C:\Python24\lib\site-packages\matplotlib\axes.py”, line 879, in add_line
xys = self._get_verts_in_data_coords(
File “C:\Python24\lib\site-packages\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 “”, line 1, in ?
File “C:\Python24\lib\site-packages\matplotlib\pylab.py”, line 2019, in plot
ret = gca().plot(*args, **kwargs)
File “C:\Python24\lib\site-packages\matplotlib\axes.py”, line 2124, in plot
self.add_line(line)
File “C:\Python24\lib\site-packages\matplotlib\axes.py”, line 879, in add_line
xys = self._get_verts_in_data_coords(
File “C:\Python24\lib\site-packages\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.

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.

···

On 2/1/07, Nicolas <nico_75_0@...136...> wrote: