leejjoon / pywcsgrid2

astromonical fits image for python matplotlib
http://leejjoon.github.com/pywcsgrid2/
MIT License
25 stars 13 forks source link

Axis labels don't follow after several set_display_coord_system and swap_tick_coord #1

Closed astrofrog closed 13 years ago

astrofrog commented 14 years ago

I have a FITS image with Galactic WCS coordinates. If I run the following code:

import pyfits
import matplotlib.pyplot as plt
import pywcsgrid2

f = pyfits.open("fake_pole.fits")
h, d = f[0].header, f[0].data

fig = plt.figure()
ax = pywcsgrid2.subplot(122, header=h)
fig.add_axes(ax)
ax.imshow(d, origin="lower")
ax.grid()
ax.set_display_coord_system("fk5")
ax.swap_tick_coord()
ax.set_display_coord_system("gal")

at the end, the labels are still the fk5 labels.

leejjoon commented 14 years ago

Thanks for reporting this. This is a bug, and I will commit the fix soon. Meanwhile, I recommend you to manually set the labels with following methods.

ax.axis["bottom"].label.set_text("$l$") ax.axis["left"].label.set_text("$b$")

On the other hand, you're misusing the pywcsgrid2.subplot command. You should not add the axes by yourself, as this is already done by the subplot command (as in the matplotlib). If you do want to do this manually, use Subplot (not subplot).

fig = plt.figure() ax = pywcsgrid2.Subplot(fig, 122, header=h) fig.add_axes(ax)

I hope this solves your issue.

-JJ

leejjoon commented 13 years ago

With leejjoon/pywcsgrid2@d7ca2af4245664a936fd321f7d388d1e6777eccc, this should work.