superplots

Module Contents

Classes

Superplot

SuperplotFormatter

class superplots.Superplot(domain=None, domain_crs=None, crs=None, rows=None, cols=None)
property cols
property distinct_legend_layers

Group layers by style.

property fig
property gridspec
property rows
property shape
property subplots_generator
MAX_COLS = 8
shaded_contour
add_geometries(*args, **kwargs)

Plot geometries on all subplots.

Parameters:
  • shapes (geopandas.GeoDataFrame or earthkit.data) –

  • shapes

  • *args

  • crs=None

  • labels=False

  • label_kwargs=None

  • **kwargs

add_subplot(*args, data=None, domain=None, crs=None, **kwargs)
borders(*args, **kwargs)
coastlines(*args, **kwargs)
contour(*args, **kwargs)
contourf(*args, **kwargs)
defer()

Defer a method’s execution until this superplot has subplots.

expand_rows_cols()
format_string(string, unique=True, grouped=True)
classmethod from_gridspec(gridspec, *args, **kwargs)

Instantiate an earthkit Superplot from a matplotlib gridspec.

Parameters:
  • gridspec (matplotlib.gridspec.GridSpec) – A matplotlib grid layout which determines subplot layout.

  • *args

  • **kwargs

gridlines(*args, **kwargs)
land(*args, **kwargs)
legend(*args, location=None, **kwargs)
ocean(*args, **kwargs)
pcolormesh(*args, **kwargs)
plot(*args, **kwargs)
polygons(*args, **kwargs)
save(*args, bbox_inches='tight', **kwargs)

Save the chart.

scatter(*args, **kwargs)
show(*args, **kwargs)

Display the chart.

stock_img(*args, **kwargs)
subplot_titles(*args, **kwargs)
title(label=None, unique=True, grouped=True, **kwargs)

Add a top-level title to the chart.

Parameters:
  • label (str, optional) – The text to use in the title. This text can include format keys surrounded by {} curly brackets, which will extract metadata from your plotted data layers.

  • unique (bool, optional) – If True, format keys which are uniform across subplots/layers will produce a single result. For example, if all data layers have the same variable_name, only one variable name will appear in the title. If False, each format key will evaluate to a list of values found across subplots/layers.

  • grouped (bool, optional) – If True, a single title will be generated to represent all data layers, with each format key evaluating to a list where layers differ - e.g. “{variable} at {time}” might be evaluated to “temperature and wind at 2023-01-01 00:00”. If False, the title will be duplicated by the number of subplots/ layers - e.g. `”{variable} at {time}” might be evaluated to `”temperature at 2023-01-01 00:00 and wind at 2023-01-01 00:00”.

  • kwargs (dict, optional) – Keyword argument to matplotlib.pyplot.suptitle (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.suptitle.html#matplotlib-pyplot-suptitle ).

class superplots.SuperplotFormatter(subplots, unique=True)

Bases: earthkit.maps.layers.metadata.BaseFormatter

convert_field(value, conversion)
format_field(value, format_spec)
format_key(key)