Plotting functions#
Cartography#
Plotting functions used with cartopy.
- class aeolus.plot.cart.GeoAxesGrid(fig, rect, nrows_ncols, projection, **axesgrid_kw)[source]#
Bases:
ImageGrid
Grid of cartopy axes.
A subclass of
mpl_toolkits.axes_grid1.AxesGrid
representing a grid of maps with the same projectionProjection
.axes_class is defined automatically
The
AxesGrid
built-in labelling is always switched off, and instead a standard procedure of creating grid lines and labels should be used.
- __init__(fig, rect, nrows_ncols, projection, **axesgrid_kw)[source]#
Initialise GeoAxesGrid.
Build a
GeoAxesGrid
instance with a grid nrows*ncolsGeoAxes
with a projectionProjection
inFigure
fig with rect=[left, bottom, width, height] (inFigure
coordinates) or the subplot position code (e.g., “121”).
- aeolus.plot.cart.label_global_map_gridlines(fig, ax, xticks=None, yticks=None, xoff=-10, yoff=-10, degree=False, **text_kw)[source]#
Label gridlines of a global cartopy map.
- Parameters:
fig (matplotlib.figure.Figure) – Figure object.
ax (cartopy.mpl.geoaxes.GeoAxesSubplot) – Cartopy axes.
xticks (array-like, optional) – Sequence of longitude ticks.
yticks (array-like, optional) – Sequence of latitude ticks.
xoff (float, optional) – Longitude label offset from the axis (units are points). If negative (by default), the labels are drawn at the east boundary, otherwise at the west boundary.
yoff (float, optional) – Latitude label offset from the axis (units are points). If negative (by default), the labels are drawn at the south boundary, otherwise at the north boundary.
degree (bool, optional) – Add a degree symbol to tick labels.
**text_kw (dict, optional) – Label text properties.
Matplotlib helpers#
Matplotlib-related utilities.
- aeolus.plot.mpl.add_custom_legend(ax_or_fig: Axes | Figure, styles_and_labels: dict, **leg_kw) None [source]#
Add a custom legend to a matplotlib axis or figure.
- Parameters:
Example
>>> import matplotlib.pyplot as plt >>> ax = plt.axes() >>> my_dict = dict(foo=dict(color='C0', marker="X"), bar=dict(color='C1', marker="o")) >>> add_custom_legend(ax, my_dict, loc=2, title="blah")
- aeolus.plot.mpl.capitalise(s: str, sep_old: str | None = '_', sep_new: str | None = ' ') str [source]#
Split the string and capitalise each word.
- aeolus.plot.mpl.figsave(fig: Figure, filename: Path, **kw_savefig) None [source]#
Save figure and print relative path to it.
- aeolus.plot.mpl.hcross(cube: ~iris.cube.Cube, ax: ~matplotlib.axes._axes.Axes | None = None, model: ~aeolus.model.base.Model | None = Model [99 fields], **kw_plt) Axes | None [source]#
Plot a horizontal cross-section aka lat-lon map of a 2D cube.
- aeolus.plot.mpl.linspace_pm1(n: int) Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] [source]#
Return 2n evenly spaced numbers from -1 to 1, always skipping 0.
- aeolus.plot.mpl.make_list_2d(list_x: Sequence[str], list_y: Sequence[str], transpose: bool | None = False) list [source]#
Create a nested list out of 2 given lists.
- aeolus.plot.mpl.map_scatter(cube: ~iris.cube.Cube, ax: ~matplotlib.axes._axes.Axes | None = None, model: ~aeolus.model.base.Model | None = Model [99 fields], **kw_plt) Axes | None [source]#
Plot a lat-lon scatter plot of a 2D cube.
Text-related functions#
Text-related formatting functions.
- aeolus.plot.text.all_sim_file_label(sims)[source]#
Make a shorter label for a list of labels with a common prefix.
- aeolus.plot.text.cube_minmeanmax_str(cube, sep=' | ', eq_sign='=', fmt='auto', weight=True, labels=None, **kw_unit_format)[source]#
Return min, mean and max of an iris cube as a string.
- aeolus.plot.text.fmt_lonlat(value, lon_or_lat, degree=False)[source]#
Convert longitude or latitude value to string with a hemisphere identifier.
- Parameters:
- Return type:
Examples
>>> fmt_lonlat(-25, "lon") '25W' >>> fmt_lonlat(89, "lat", degree=True) '89$^\\degree$N' >>> fmt_lonlat(0, "lon") '0'
- aeolus.plot.text.subplot_label_generator()[source]#
Return generator of alphabetic labelling of subplots.
- aeolus.plot.text.tex2cf_units(unit_str)[source]#
Convert a TeX string to a string that can be used in cf_units.
- aeolus.plot.text.unit_format(value, unit='1', decimal_digits=1, precision=None, exponent=None)[source]#
Return a string representation of a given number with units.
Format the scientific notation of the given number for use with LaTeX, with specified number of significant decimal digits and precision (number of decimal digits to show). The exponent to be used can also be specified explicitly.
- Parameters:
- Return type:
Examples
>>> unit_format(-1.234e-5) '$-1.2\\times10^{-5}$' >>> unit_format(6) '$6.0$' >>> unit_format(1.234e5, unit="m s^{-1}") '$1.2\\times10^{5}$ $m$ $s^{-1}$' >>> unit_format(1.234, decimal_digits=1, precision=3) '$1.200$' >>> unit_format(1.234, decimal_digits=3, precision=1) '$1.2$'