Colormap functions¶
Overview¶
The plotpy.mathutils.colormap module contains definition of common colormaps
and tools to manipulate and create them.
The following functions are available:
get_cmap(): get a colormap from its namecmap_exists(): check if a colormap existsadd_cmap(): add a colormap to the list of available colormapsbuild_icon_from_cmap(): build an icon representing the colormapbuild_icon_from_cmap_name(): build an icon representing the colormap from its name
Reference¶
- plotpy.mathutils.colormap.get_cmap(cmap_name: str) EditableColormap[source]¶
Returns the colormap with the given name from the ALL_COLORMAPS global variable. If the colormap is not found, returns the DEFAULT colormap.
- Parameters:
cmap_name – colormap name to search in ALL_COLORMAPS. All keys in ALL_COLORMAPS are lower case, so the given name is also lowered.
- Returns:
A CustomQwtLinearColormap instance corresponding to the given name, if no colormap is found, returns the DEFAULT colormap.
- plotpy.mathutils.colormap.cmap_exists(cmap_name: str, cmap_dict: Dict[str, EditableColormap] | None = None) bool[source]¶
Returns True if the colormap with the given name exists in the given colormap dictionary, False otherwise. If no dictionary is given, the ALL_COLORMAPS global variable is used.
- Parameters:
cmap_name – colormap name to search in given colormap dictionnary. All keys in the dictionary are lower case, so the given name is also lowered.
cmap_dict – colormap dictionnary to search in. If None, ALL_COLORMAPS is used.
- Returns:
True if the colormap exists, False otherwise.
- plotpy.mathutils.colormap.add_cmap(cmap: EditableColormap) None[source]¶
Adds the given colormap to both ALL_COLORMAPS and CUSTOM_COLORMAPS global variables.
- Parameters:
cmap – colormap to add
- plotpy.mathutils.colormap.build_icon_from_cmap(cmap: EditableColormap, width: int = 16, height: int = 7, orientation: Literal['h', 'v'] = 'h', margin: int = 0) QIcon[source]¶
Builds an icon representing the colormap
- Parameters:
cmap – colormap
width – icon width
height – icon height
orientation – orientation of the colormap in the icon. Can be “h” for horizontal or “v” for vertical
margin – margin around the colormap in the icon. Beware that the margin is included in the given icon size. For example, if margin is 1 and width is 16, the actual colormap width will be 14 (16 - 2 * 1). This was done to prevent interpolation on display.
- plotpy.mathutils.colormap.build_icon_from_cmap_name(cmap_name: str, width: int = 16, height: int = 7, orientation: Literal['h', 'v'] = 'h', margin: int = 0) QIcon[source]¶
Builds an QIcon representing the colormap from the colormap name found in ALL_COLORMAPS global variable.
- Parameters:
cmap_name – colormap name to search in ALL_COLORMAPS
width – icon width
height – icon height
orientation – orientation of the colormap in the icon. Can be “h” for horizontal or “v” for vertical
margin – margin around the colormap in the icon. Beware that the margin is included in the given icon size. For example, if margin is 1 and width is 16, the actual colormap width will be 14 (16 - 2 * 1). This was done to prevent interpolation on display.
- Returns:
QIcon representing the colormap