terrain_cmap_factory#

pycraf.pathprof.terrain_cmap_factory(sealevel=0.5, vmin=-50, vmax=1200)[source]#

Produce terrain colormap and norm to be used in plt.imshow.

With this, one can adjust the colors in the cmap such that the sea level is properly defined (blue).

A simple use case would look like the following:

>>> vmin, vmax = -20, 1200  
>>> terrain_cmap, terrain_norm = terrain_cmap_factory(vmin=vmin, vmax=vmax)  
>>> plt.imshow(  
...     heights, cmap=terrain_cmap, norm=terrain_norm,
...     # vmin=vmin, vmax=vmax  # deprecated in newer matplotlib versions
...     )
Parameters:
sealevelfloat

The sealevel value.

vmin/vmaxfloat

Minimum/maximum height to cover in the colormap (Default: -50, 1200) (sealevel must be between vmin and vmax!)

Returns:
terrain_cmapmatplotlib.colors.LinearSegmentedColormap
terrain_normmatplotlib.colors.Normalize instance