lair.plotter.terrain_cmap#

lair.plotter.terrain_cmap(minval=0.42, maxval=1.0, n=256)[source]#

Matplotlib terrain cmap.

Parameters:
  • minval (float, optional) – Minimum value to truncate the colormap. Defaults to 0.42.

  • maxval (float, optional) – Maximum value to truncate the colormap. Defaults to 1.0.

  • n (int, optional) – Number of colors in the new colormap. Defaults to 256.

Returns:

matplotlib.colors.LinearSegmentedColormap – Matplotlib terrain colormap.

Return type:

LinearSegmentedColormap

See also

truncate_colormap

What it calls, for any colormap.

Examples

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from lair.plotter import terrain_cmap
>>> gradient = np.linspace(0, 1, 256).reshape(1, -1)
>>> fig, ax = plt.subplots(figsize=(6, 0.6))
>>> mesh = ax.imshow(gradient, aspect="auto", cmap=terrain_cmap())
>>> ax.set_axis_off()
../_images/lair-plotter-terrain_cmap-1.png