Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added docs/_static/images/plot-with-clim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ Gallery
:width: 200
:class: no-scaled-link

* - :ref:`example-plot-with-clim`

.. image:: /_static/images/plot-with-clim.png
:width: 200
:class: no-scaled-link
30 changes: 30 additions & 0 deletions docs/examples/plot-with-clim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import cartopy.crs
import emsarray
import emsarray.plot
from cartopy.feature import GSHHSFeature
from matplotlib import pyplot

ds = emsarray.tutorial.open_dataset('austen')

figure = pyplot.figure(figsize=(10, 8), layout='constrained')
axes = figure.add_subplot(projection=cartopy.crs.PlateCarree())
axes.set_aspect('equal', adjustable='datalim')

polys = ds.ems.make_poly_collection(
ds['eta'].isel(record=0),
clim=(-3, 3), edgecolor='face',
cmap='Spectral',
)
axes.add_collection(polys)
figure.colorbar(polys, ax=axes, location='right', label="metres")

coast = GSHHSFeature(scale='intermediate')
axes.add_feature(coast, facecolor='linen', edgecolor='darkgrey', linewidth=0.5)

axes.autoscale()
axes.set_title("Sea surface height deviation")
axes.set_facecolor('aliceblue')

figure.savefig('plot-with-clim.png')

pyplot.show(block=True)
23 changes: 23 additions & 0 deletions docs/examples/plot-with-clim.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _example-plot-with-clim:

===============================
Plot with specified data limits
===============================

The :meth:`Convention.make_poly_collection()` method passes all keyword arguments
on to :class:`~matplotlib.collections.PolyCollection`.
This can be used to customise the appearance of the collection
and to set parameters such as `clim`:

.. image:: /_static/images/plot-with-clim.png
:alt: A plot of sea surface height deviation from the Australia wide AUSTEn dataset.
The limits of the colour bar have been constrianed to (-3, 3).

Code
====

:download:`Download plot-with-clim.py example <plot-with-clim.py>`.

.. literalinclude:: plot-with-clim.py
:language: python

3 changes: 3 additions & 0 deletions docs/releases/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ Next release (in development)
* Fixed issues with detecting topology variables in SHOC datasets
where some variables are lacking a `standard_name` (:issue:`178`, :pr:`180`).
* Updated the tests to be compatible with the latest xarray versions (:pr:`182`).
* Added an example to the documentation showing
:ref:`how to set the clim parameter in plots <example-plot-with-clim>`
(:pr:`179`).
Loading