Plotting utilities and functions

The package uses a few utility classes and functions to make consistent plotting easy thoughout the package. This reference page documents the lower-level utilities used to make this happen.

Note

The built-in routines to plot Section and Plan objects are not documented here, look for documentation on those high-level methods in their respective module documentation.

The functions are defined in deltametrics.plot.

Default styling

By default, each variable receives a set of styling definitions. The default parameters of each styling variable are defined below:

(png, hires.png)

../../_images/document_variableset.png

Plotting utility objects

VariableInfo(name, **kwargs)

Variable styling and information.

VariableSet([override_dict])

A default set of properties for variables.

Plotting utility functions

deltametrics.plot.append_colorbar(ci, ax)

Append a colorbar, consistently placed.

Adjusts some parameters of the parent axes as well.

Parameters
  • ci (matplotlib.pyplot.pcolormesh, matplotlib.pyplot.ImageAxes) – The colored object generated via matplotlib that the colormap should be stolen from.

  • ax (matplotlib.Axes) – The instance of axes to place the colorbar next to.

  • adjust (bool) – Whether to adjust some minor attributes of the parent axis, for presentation.

Returns

cb – The colorbar instance created.

Return type

matplotlib.colorbar instance.

deltametrics.plot.get_display_arrays(VarInst, data=None)

Get arrays for display of Variables.

Function takes as argument a VariableInstance from a Section or Planform and an optional data argument, which specifies the data type to return, and gives back arrays of 1) data, 2) display x-coordinates and 3) display y-coordinates.

Parameters
  • VarInst (BaseSectionVariable subclass) – The Variable instance to visualize. May be any subclass of BaseSectionVariable or BasePlanformVariable.

  • data (str, optional) – The type of data to visualize. Supported options are ‘spacetime’, ‘preserved’, and ‘stratigraphy’. Default is to display full spacetime plot for variable generated from a DataCube, and stratigraphy for a StratigraphyCube variable. Note that variables sourced from a StratigraphyCube do not support the spacetime or preserved options, and a variable from DataCube will only support stratigraphy if the Cube has computed “quick” stratigraphy.

Returns

data, X, Y – Three matching-size ndarray representing the 1) data, 2) display x-coordinates and 3) display y-coordinates.

Return type

ndarray

deltametrics.plot.get_display_lines(VarInst, data=None)

Get lines for display of Variables.

Function takes as argument a VariableInstance from a Section or Planform and an optional data argument, which specifies the data type to return, and gives back data and line segments for display.

Parameters
  • VarInst (BaseSectionVariable subclass) – The Variable instance to visualize. May be any subclass of BaseSectionVariable or BasePlanformVariable.

  • data (str, optional) – The type of data to visualize. Supported options are ‘spacetime’, ‘preserved’, and ‘stratigraphy’. Default is to display full spacetime plot for variable generated from a DataCube. and stratigraphy for a StratigraphyCube variable. Variables from DataCube will only support stratigraphy if the Cube has computed “quick” stratigraphy.

  • note:: (.) – Not currently implemented for variables from the StratigraphyCube.

Returns

vals, segments – An off-by-one sized array of data values (vals) to color the line segments (segments). The segments are organized along the 0th dimension of the array.

Return type

ndarray

deltametrics.plot.get_display_limits(VarInst, data=None)

Get limits to resize the display of Variables.

Function takes as argument a VariableInstance from a Section or Planform and an optional data argument, which specifies how to determine the limits to return.

Parameters
  • VarInst (BaseSectionVariable subclass) – The Variable instance to visualize. May be any subclass of BaseSectionVariable or BasePlanformVariable.

  • data (str, optional) – The type of data to compute limits for. Typically this will be the same value used with either get_display_arrays or get_display_lines. Supported options are ‘spacetime’, ‘preserved’, and ‘stratigraphy’.

Returns

xmin, xmax, ymin, ymax – Values to use as limits on a plot. Use with, for example, ax.set_xlim((xmin, xmax)).

Return type

float

deltametrics.plot._fill_steps(where, x=1, y=1, y0=0, **kwargs)

Fill rectangles where the boolean indicates True.

Creates an x by y matplotlib.patches.Rectangle at each index where the index i in boolean where indicates, with the lower left of the patch at (i, y0).

This utility function is utilized internally. Most often, it is used to highlight where time has been preserved (or eliminated) in a timeseries of data. For example, see show_one_dimensional_trajectory_to_strata.

Parameters
  • where (ndarray) – Boolean numpy ndarray indicating which locations to create a patch at.

  • x (float) – The x-direction width of the Rectangles.

  • y (float) – The y-direction height of the Rectangles.

  • y0 (float) – The y-direction origin (i.e., lower-left y-value) of the Rectangles.

  • **kwargs – Additional matplotlib keyword arguments passed to the Rectangle instantiation. This is where you can set most matplotlib **kwargs (e.g., color, edgecolor).

Returns

pc – Collection of Rectangle Patch objects.

Return type

matplotlib.patches.PatchCollection

DeltaMetrics plot routines

show_one_dimensional_trajectory_to_strata(e)

1d elevation to stratigraphy.

DeltaMetrics colormaps

deltametrics.plot.cartographic_colormap()

Colormap for an elevation map style.

Warning

Not implemented.

Note

This should implement something that looks like this, and should be configured to always setting the break to whatever sea-level is (or zero?).

deltametrics.plot.aerial_colormap()

Colormap for a pesudorealistic looking aerial shot.

Warning

Not implemented.