nbnode.plot package

Submodules

nbnode.plot.shifted_colormap module

nbnode.plot.shifted_colormap.shifted_colormap(cmap, min_val, max_val, name) Colormap[source]

Function to offset the “center” of a colormap.

Useful for data with a negative min and positive max and you want the middle of the colormap’s dynamic range to be at zero.

Adapted from https://stackoverflow.com/questions/7404116/defining-the-midpoint-of-a-colormap-in-matplotlib Post of DaveTheScientist

Parameters:
  • cmap – The matplotlib colormap to be altered.

  • start – Offset from lowest point in the colormap’s range. Defaults to 0.0 (no lower ofset). Should be between 0.0 and midpoint.

  • midpoint – The new center of the colormap. Defaults to 0.5 (no shift). Should be between 0.0 and 1.0. In general, this should be 1 - vmax/(vmax + abs(vmin)) For example if your data range from -15.0 to +5.0 and you want the center of the colormap at 0.0, midpoint should be set to 1 - 5/(5 + 15)) or 0.75

  • stop – Offset from highets point in the colormap’s range. Defaults to 1.0 (no upper ofset). Should be between midpoint and 1.0.

Returns:

_description_

Return type:

Colormap

nbnode.plot.utils module

class nbnode.plot.utils.LinearShiftedColormap(range_min: float = -1, range_max: float = 1, base_cmap=<matplotlib.colors.LinearSegmentedColormap object>, name: str = 'shifted')[source]

Bases: object

A linear shifted colormap.

Takes a base colormap and scales/stretches it between min_val and max_val.

nbnode.plot.utils.flatten(S: List)[source]

Flatten any list of (nested) lists.

Flattens further until the element to flatten is not a list.

Parameters:

S (List) – A list containing elements, lists and/or nested lists.

Returns:

A flattened list.

Return type:

_type_

nbnode.plot.utils.plot_save_unified(any_plot, file: str, **kwargs)[source]

Save a plot in a unified way.

Parameters:
  • any_plot (_type_) – A plot object. E.g. a matplotlib plot/figure.

  • file (str) – The file to save the plot to.

Module contents