Utility functions for plottingΒΆ

sciutils.plot.alpha_cmap(color, name='')ΒΆ

Create a monochrome colormap that maps scalars to varying transparencies.

Parameters
  • color (str, int, or tuple) – Base color to use for the colormap.

  • name (str) – Name of the colormap.

  • **kwargs (dict) – Keyword arguments passed to mpl.colors.LinearSegmentedColormap.from_list().

Returns

cmap – Colormap encoding scalars as transparencies.

Return type

mpl.colors.Colormap

sciutils.plot.evaluate_pcolormesh_edges(x, scale='linear')ΒΆ

Evaluate the n + 1 edges of cells for a pcolormesh visualisation for n cell centroids.

Parameters
  • x (np.ndarray) – Centroids of the pcolormesh cells.

  • scale (str) – Find the arithmetic midpoints if linear and the geometric midpoints if log.

Returns

edges – Edges of pcolormesh cells.

Return type

np.ndarray

sciutils.plot.plot_geometry(geometries, aspect='equal', autoscale=True, scale=1, ax=None, **kwargs)ΒΆ

Plot a shapely geometry using a polygon collection.

Note

This function does not plot holes in polygons.

Parameters
  • geometries – Geometry to plot or sequence thereof.

  • aspect (str or float, optional) – Aspect ratio of the plot.

  • autoscale (bool, optional) – Whether to autoscale the plot.

  • ax (optional) – Axes to use for plotting.

  • **kwargs (dict) – Keyword arguments passed to matplotlib.collections.PolyCollection.

Returns

collection – Collection of polygons.

Return type

matplotlib.collections.PolyCollection