## matplotlib-users

 [Matplotlib-users] Coordinate transformations and second axis From: Pim Schellart - 2009-10-07 10:14:48 ```Hi Everyone, after trying every example I could find in the documentation, gallery and online I thought let's give the mailing list a try. I have an image displayed with imshow. I would like to display the pixel coordinates on the left y and bottom x axis and the physical coordinates (in arcseconds) on the right y and top x axis. I tried it with twinx & twiny but then only a part of the image is shown (image is in pixel coordinates), I also tried creating a new axes object with ax2=plt.subplot(1,1,1, frameon=False) but then the image is no longer shown (this might be a bug). Is this possible with the current version (0.99) of matplotlib? Kind regards, Pim Schellart ```
 Re: [Matplotlib-users] Coordinate transformations and second axis From: Jae-Joon Lee - 2009-10-07 17:05:27 ```As far as I know, there is no easy way to do that with mpl (especially when image is involved). You may manually add ticks and ticklabels (but without using set_ticks, etc). If you're using 0.99 and later, you may use axes_grid toolkit, but it has some cons. So, if you're going to use it, please read through the documentation. from mpl_toolkits.axes_grid.parasite_axes import SubplotHost import matplotlib.pyplot as plt import matplotlib.transforms as mtransforms fig = plt.figure(1, (4,3)) ax = SubplotHost(fig, 111) fig.add_subplot(ax) ax.imshow([[1,2],[3,4]], origin="lower") # transform from arcsecond to pixel tr = mtransforms.Affine2D().translate(+1,+1).scale(2., 2.) ax2 = ax.twin(tr) plt.show() Regards, -JJ On Wed, Oct 7, 2009 at 6:14 AM, Pim Schellart wrote: > Hi Everyone, > > after trying every example I could find in the documentation, gallery > and online I thought let's give the mailing list a try. > I have an image displayed with imshow. > I would like to display the pixel coordinates on the left y and bottom > x axis and the physical coordinates (in arcseconds) on the right y and > top x axis. > I tried it with twinx & twiny but then only a part of the image is > shown (image is in pixel coordinates), I also tried creating a new > axes object with ax2=plt.subplot(1,1,1, frameon=False) but then the > image is no longer shown (this might be a bug). > Is this possible with the current version (0.99) of matplotlib? > > Kind regards, > > Pim Schellart > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```