subplots

Attributes

DEFAULT_FORMATS

TARGET_DENSITY

ZERO_FORMATS

Classes

Subplot

A single plot within a Figure.

Functions

thin_array(array[, every])

Reduce the size of an array by taking every `every`th element.

Module Contents

subplots.DEFAULT_FORMATS = ['%Y', '%b', '%-d', '%H:%M', '%H:%M', '%S.%f']
class subplots.Subplot(row=0, column=0, figure=None, **kwargs)

A single plot within a Figure.

A Subplot is a container for one or more Layers, each of which is a plot of a single data source.

Parameters:
  • row (int, optional) – The row index of the subplot in the Figure.

  • column (int, optional) – The column index of the subplot in the Figure.

  • figure (Figure, optional) – The Figure to which the subplot belongs.

  • **kwargs – Additional keyword arguments to pass to the matplotlib Axes constructor.

property ax

The underlying matplotlib Axes object.

bar(*args, **kwargs)

Plot a bar chart on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x and y must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the bar chart. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.bar.

barbs(*args, **kwargs)

Plot wind barbs on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, u, and v must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • u (str, list, numpy.ndarray, or xarray.DataArray, optional) – The u values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • v (str, list, numpy.ndarray, or xarray.DataArray, optional) – The v values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the wind barbs. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.barbs.

block(*args, **kwargs)
abstract coastlines(*args, **kwargs)
column = 0
contour(*args, **kwargs)

Plot a contour plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the contour plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.contour.

contourf(*args, **kwargs)

Plot a filled contour plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the filled contour plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.contourf.

property distinct_legend_layers

Layers on this subplot which have a unique Style.

domain = None
envelope(data_1, data_2=0, alpha=0.4, **kwargs)
property fig

The underlying matplotlib Figure object.

property figure
format_string(string, unique=True, grouped=True)

Format a string with metadata from the Subplot.

Parameters:
  • string (str) – The string to format. This can contain metadata keys in curly braces, e.g. “{variable_name}”.

  • unique (bool, optional) – Whether to use unique metadata values from each Layer. If False, metadata values from all Layers are combined.

  • grouped (bool, optional) – Whether to group metadata values from all Layers into a single string. If False, metadata values from each Layer are listed separately.

grid_cells
abstract gridlines(*args, **kwargs)
hsv_composite(*args)
isolines(*args, **kwargs)
labels(data=None, label=None, x=None, y=None, **kwargs)
layers = []
legend(style=None, location=None, **kwargs)

Add a legend to the Subplot.

Parameters:
  • style (Style, optional) – The Style to use for the legend. If None (default), a legend is created for each Layer with a unique Style. If a single Style is provided, a single legend is created based on that Style.

  • location (str or tuple, optional) – The location of the legend(s). Must be a valid matplotlib location (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html).

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.legend.

line(*args, **kwargs)

Plot a line on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x and y must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the line. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.plot.

pcolormesh(*args, **kwargs)

Plot a pcolormesh on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the pcolormesh. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.pcolormesh.

plot(data, style=None, units=None, **kwargs)
plot_2D(extract_domain=False)
plot_3D(extract_domain=False)
plot_box()
plot_vector()
quantiles(data, quantiles=[0, 1], dim=None, alpha=0.15, **kwargs)
quickplot(data, style=None, units=None, **kwargs)
quiver(*args, **kwargs)

Plot arrows on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, u, and v must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • u (str, list, numpy.ndarray, or xarray.DataArray, optional) – The u values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • v (str, list, numpy.ndarray, or xarray.DataArray, optional) – The v values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the quiver plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.quiver.

rgb_composite(*args)
row = 0
save(*args, **kwargs)

Save the plot to a file.

scatter(*args, **kwargs)

Plot a scatter plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x and y must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the scatter plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.scatter.

set_major_xticks(frequency=None, format=None, highlight=None, highlight_color='red', **kwargs)
set_minor_xticks(frequency=None, format=None, **kwargs)
show()

Display the plot.

title(label=None, unique=True, wrap=True, capitalize=True, **kwargs)

Add a title to the plot.

Parameters:
  • label (str, optional) – The title text. If None, a default template is used. The template can contain metadata keys in curly braces, e.g. “{variable_name}”.

  • unique (bool, optional) – Whether to use unique metadata values from each Layer. If False, metadata values from all Layers are combined.

  • wrap (bool, optional) – Whether to wrap the title text. Default is True.

  • capitalize (bool, optional) – Whether to capitalize the first letter of the title. Default is True.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.title.

tricontour(*args, **kwargs)

Plot a tricontour plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the tricontour plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.tricontour.

tricontourf(*args, **kwargs)

Plot a filled tricontour plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the filled tricontour plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.tricontourf.

tripcolor(*args, **kwargs)

Plot a tripcolor plot on the Subplot.

Parameters:
  • data (list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional) – The data to plot. If None, x, y, and z must be provided.

  • x (str, list, numpy.ndarray, or xarray.DataArray, optional) – The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • y (str, list, numpy.ndarray, or xarray.DataArray, optional) – The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • z (str, list, numpy.ndarray, or xarray.DataArray, optional) – The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided.

  • style (earthkit.plots.styles.Style, optional) – The Style to use for the tripcolor plot. If None, a Style is automatically generated based on the data.

  • **kwargs – Additional keyword arguments to pass to matplotlib.pyplot.tripcolor.

subplots.TARGET_DENSITY = 40
subplots.ZERO_FORMATS = ['%Y', '%b', '%-d', '%H:%M', '%H:%M', '%S.%f']
subplots.thin_array(array, every=2)

Reduce the size of an array by taking every `every`th element.

Parameters:
  • array (numpy.ndarray) – The array to thin.

  • every (int, optional) – The number of elements to skip.