Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions episodes/06-units_and_quantities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down