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

Show off quantity_support() in units notebook #238

Open
mhvk opened this issue Jun 14, 2024 · 1 comment
Open

Show off quantity_support() in units notebook #238

mhvk opened this issue Jun 14, 2024 · 1 comment

Comments

@mhvk
Copy link

mhvk commented Jun 14, 2024

Suggestion by @eerovaher - it is really nice that one can make plots that automatically show the units on the labels (and convert different elements). Would be nice to include that in the notebook -- and possibly even in the slides!
See https://docs.astropy.org/en/stable/visualization/matplotlib_integration.html

@eerovaher
Copy link
Member

It might be a good idea to highlight quantity_support(), but what I suggested was even simpler:

Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.24.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from astropy import units as u

In [2]: q = 5 * u.km / u.s

In [3]: f"{q:latex_inline}"
Out[3]: '$5 \\; \\mathrm{km\\,s^{-1}}$'

In [4]: f"{q.unit:unicode}"
Out[4]: 'km s⁻¹'

I have found this to be very useful in plot titles, legends and labels.

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

No branches or pull requests

2 participants