Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to rotate y-axis tick labels or re-format it based on units #347

Open
astrochun opened this issue Jun 1, 2017 · 5 comments
Open
Labels

Comments

@astrochun
Copy link

I'm generating plots where the WCS from the FITS header is wavelength for the y-axis. Because the spacing is large enough, it would be a better use of space to rotate the tick labels by 90 deg. This is possible in matplotlib but not in aplpy.

If this is not possible, an alternative approach is to provide units and set the units for the tick marks. Thus, instead of having a tick mark labelled as 10000 Ang, it would be 1.0 micron.

Is either of these two options possible?

FYI: I'm using v1.1.1 of aplpy

@brewstronomy
Copy link

I'd like to second this request. Is there a hack-y way to accomplish this in the meantime?

@astrochun
Copy link
Author

@lpbeale93: I have yet to find a way to do it.

@ashleythomasbarnes
Copy link

Putting this fix here, as I've just come across this myself... Nonetheless, it would be good have this functionality built in.

For version < 2 you could use:

 ax_ = fig.axes[0]
 for tick in ax_.get_yticklabels():
     tick.set_rotation(90)

For version > 2 you could use:

axes = fig.get_axes()
lat = axes[0].coords[1]
lat.ticklabels.set_rotation(90)

@FlaAmaral
Copy link

Putting this fix here, as I've just come across this myself... Nonetheless, it would be good have this functionality built in.

For version < 2 you could use:

 ax_ = fig.axes[0]
 for tick in ax_.get_yticklabels():
     tick.set_rotation(90)

For version > 2 you could use:

axes = fig.get_axes()
lat = axes[0].coords[1]
lat.ticklabels.set_rotation(90)

@ashleythomasbarnes sorry for the stupid question, but where does "coords" come from? I am getting an error "AttributeError: 'AxesSubplot' object has no attribute 'coords'". Thank you!!!

@ashleythomasbarnes
Copy link

ashleythomasbarnes commented Jan 10, 2023

How many axes are you using? Does axes = fig.get_axes()[0] return <WCSAxesSubplot:xlabel='RA (ICRS)', ylabel='Dec (ICRS)'> otherwise you may need to use lat = axes[1].coords[1] or lat = axes[2].coords[1] etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants