Thomas Robitaille wrote: > It looks like rotation/translation should be easy to do with Affine2D, > so I tried using it, but I can't seem to get it to work as expected - > here is an example of how I am using it:
Based on a quick look at image.py and _image.cpp, it appears that there is a low-level capability to rotate an image in the latter, but no support at higher levels. It also looks to me like adding that support would not be trivial--doing it right would take more than just calling the low-level apply_rotation method. Mike D. would be the expert on this, though. Eric > > import numpy as np > from matplotlib.pyplot import * > from matplotlib.transforms import Affine2D > > im = np.random.random((10,10)) > tr = Affine2D().rotate_deg(45.) > > fig = figure() > ax = fig.add_subplot(111) > ax.imshow(im,transform=tr) > fig.canvas.draw() > > Am I doing something wrong? > > Thanks! > > Thomas > > On Mar 13, 2009, at 5:20 PM, Andrew Straw wrote: > >> Eric Firing wrote: >>> Thomas Robitaille wrote: >>>> Hello, >>>> >>>> I was wondering whether there is a way to rotate a grayscale/ >>>> colorscale when using imshow. >>>> >>>> I have been using PGPLOT (a fortran/c plotting library) for many years >>>> now, and the equivalent to imshow is called PGGRAY (or PGIMAG). One of >>>> the arguments this function takes is a 6-element array TR which is a >>>> transformation matrix. From the PGPLOT documentation: >>>> >>>> "The transformation matrix TR is used to calculate the world >>>> coordinates of the center of the "cell" that represents each array >>>> element. The world coordinates of the center of the cell corresponding >>>> to array element A(I,J) are given by: >>>> X = TR(1) + TR(2)*I + TR(3)*J >>>> Y = TR(4) + TR(5)*I + TR(6)*J" >>> >>> You could do this with the Axes.pcolormesh method. You could start with >>> an unrotated grid (generated by meshgrid, for example), apply your >>> rotation, and use that transformed grid in pcolormesh. Note that >>> pcolormesh requires the grid for the cell boundaries, not centers. >>> >> >> It should work with imshow() as well if you can set the affine component >> of the transform to the desired values. Which it looks like you can in >> Affine2D(). (The affine matrix is the elements of TR listed above, it >> appears.) >> >> I have not tried to do this, however -- just saying that I think it's >> possible. >> >> -Andrew > ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users