terrain_cmap_factory

pycraf.pathprof.terrain_cmap_factory(sealevel=0.5, vmax=1200)[source] [edit on github]

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(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.

vmaxfloat

Maximum height to cover in the colormap (Default: 1200) (in older matplotlib versions, one should call plt.imshow with the same vmax option, and vmin=-20!)

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