diff --git a/episodes/06-units_and_quantities.md b/episodes/06-units_and_quantities.md index 7de6ffd..de8b48c 100644 --- a/episodes/06-units_and_quantities.md +++ b/episodes/06-units_and_quantities.md @@ -323,6 +323,7 @@ Support has been added for using the units information in matplotlib plots. To u ```python from astropy.visualization import quantity_support +quantity_support() # see note below ``` We will create a numpy array of the angles between 0-180 degrees, and plot the sin of these: @@ -344,6 +345,17 @@ plt.plot(angles.to(u.rad), np.sin(angles)) ![](fig/sin_curve_rad.png){alt='Plot of sin curve for degrees between 0-180'} +::::::::::::::::: callout +NOTE +The call to `quantity_support()` is required to "patch" `matplotlib` to recognize the `astropy.units`, and it will affect anything you plot from that point onward. +If you only need `quantity_support` for some plots, you can use a _context manager_: + +```python +with quantity_support(): + plt.plot(angles, np.sin(angles)) +``` +::::::::::::::::::::::::: + ## Temperature Each of the temperature scales is considered as using an irreducible unit in standard usage. As a consequence of this we need to always specify that we are using the `u.temperature` equivalences when we convert between these: