excolor.cmaptools

excolor.cmaptools.show_colorbar()[source]
excolor.cmaptools.show_cmap(cmap, verbose=True)[source]

Displays a colormap’s colorbar, sample colors, and background color.

This function displays a colormap’s colorbar, sample colors, and background color. If verbose is True, it also prints information about the colormap’s properties.

Parameters:
Returns:

Displays the colormap and its properties using matplotlib.

Return type:

None

Examples

>>> show_cmap('viridis')  # Display with default sampling
>>> gradient = np.logspace(0, -2, 10)  # Custom logarithmic sampling
>>> show_cmap('viridis', gradient)
excolor.cmaptools.list_cmaps(category='All', display=False)[source]

Lists and shows all registered colormaps.

This function prints a list of all available colormaps in matplotlib, along with their properties (e.g., Qualitative, Continuous, Divergent, Cyclic). If a category other than ‘All’ is provided, the colormaps are displayed as a grid.

Parameters:
  • category (str, default='All') – ‘All’ : list all colormaps ‘Qualitative’ : list only qualitative colormaps ‘Continuous’ : list only continuous colormaps ‘Divergent’ : list only divergent colormaps ‘Cyclic’ : list only cyclic colormaps

  • display (bool, default=False) – If True, display the colormaps as a grid.

Return type:

None

Examples

>>> list_cmaps()  # List all colormaps
>>> list_cmaps("Qualitative")  # List and display each colormap
excolor.cmaptools.list_qualitative_cmaps(display=False)[source]

Displays all qualitative colormaps in a grid layout.

This function creates a grid of all qualitative colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:

display (bool, default=False) – If True, display the colormaps as a grid.

Returns:

Displays the grid of qualitative colormaps using matplotlib

Return type:

None

Examples

>>> show_qualitative_cmaps()  # Display all qualitative colormaps
excolor.cmaptools.list_continuous_cmaps(display=False)[source]

Displays all continuous colormaps in a grid layout.

This function creates a grid of all continuous colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:

display (bool, default=False) – If True, display the colormaps as a grid.

Returns:

Displays the grid of continuous colormaps using matplotlib

Return type:

None

Examples

>>> show_continuous_cmaps()  # Display all continuous colormaps
excolor.cmaptools.list_divergent_cmaps(display=False)[source]

Displays all divergent colormaps in a grid layout.

This function creates a grid of all divergent colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:

display (bool, default=False) – If True, display the colormaps as a grid.

Returns:

Displays the grid of divergent colormaps using matplotlib

Return type:

None

Examples

>>> show_divergent_cmaps()  # Display all divergent colormaps
excolor.cmaptools.list_cyclic_cmaps(display=False)[source]

Displays all cyclic colormaps in a grid layout.

This function creates a grid of all cyclic colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:

display (bool, default=False) – If True, display the colormaps as a grid.

Returns:

Displays the grid of cyclic colormaps using matplotlib

Return type:

None

Examples

>>> show_cyclic_cmaps()  # Display all cyclic colormaps
excolor.cmaptools.logscale_cmap(cmap, norders=3)[source]

Creates a logarithmic colormap by extending the input colormap with interpolated colors.

This function takes a colormap and creates a new colormap with colors interpolated on a logarithmic scale. This is useful for visualizing data with a large dynamic range.

Parameters:
  • cmap (str or matplotlib.colors.Colormap) – Input colormap name or instance

  • norders (int, default=3) – Number of orders of magnitude to span in the logarithmic scale. The resulting colormap will have 2 * norders colors.

Returns:

A new colormap with colors interpolated on a logarithmic scale. The name of the new colormap will be ‘log_’ prefixed to the original name.

Return type:

matplotlib.colors.Colormap

Examples

>>> cmap = logscale_cmap('viridis', norders=2)
>>> plt.imshow(data, cmap=cmap)
excolor.cmaptools.get_bgcolor(cmap)[source]

Gets background color for a given colormap.

Parameters:

cmap (str or matplotlib.colors.Colormap) – Colormap name or instance. If a string is provided, it will be converted to a Colormap object.

Returns:

color – Background color in hex format. The color is determined by: - Predefined background colors for known colormaps - The darkest color from the colormap, darkened by 80% for unknown colormaps

Return type:

str

Examples

>>> get_bgcolor('viridis')
'#0E0717'
>>> get_bgcolor(plt.cm.viridis)
'#0E0717'
excolor.cmaptools.show_cmaps(category='All')[source]

Lists and shows all registered colormaps.

This function prints a list of all available colormaps in matplotlib, along with their properties (e.g., Qualitative, Continuous, Divergent, Cyclic). If a category other than ‘All’ is provided, the colormaps are displayed as a grid.

Parameters:
  • category (str, default='All') – ‘All’ : list all colormaps ‘Qualitative’ : list only qualitative colormaps ‘Continuous’ : list only continuous colormaps ‘Divergent’ : list only divergent colormaps ‘Cyclic’ : list only cyclic colormaps

  • display (bool, default=False) – If True, display the colormaps as a grid.

Return type:

None

Examples

>>> list_cmaps()  # List all colormaps
>>> list_cmaps("Qualitative")  # List and display each colormap
excolor.cmaptools.show_qualitative_cmaps(category='All')[source]

Displays all qualitative colormaps in a grid layout.

This function creates a grid of all qualitative colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:
  • display (bool, default=False) – If True, display the colormaps as a grid.

  • category (str)

Returns:

Displays the grid of qualitative colormaps using matplotlib

Return type:

None

Examples

>>> show_qualitative_cmaps()  # Display all qualitative colormaps
excolor.cmaptools.show_continuous_cmaps(category='All')[source]

Displays all continuous colormaps in a grid layout.

This function creates a grid of all continuous colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:
  • display (bool, default=False) – If True, display the colormaps as a grid.

  • category (str)

Returns:

Displays the grid of continuous colormaps using matplotlib

Return type:

None

Examples

>>> show_continuous_cmaps()  # Display all continuous colormaps
excolor.cmaptools.show_divergent_cmaps(category='All')[source]

Displays all divergent colormaps in a grid layout.

This function creates a grid of all divergent colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:
  • display (bool, default=False) – If True, display the colormaps as a grid.

  • category (str)

Returns:

Displays the grid of divergent colormaps using matplotlib

Return type:

None

Examples

>>> show_divergent_cmaps()  # Display all divergent colormaps
excolor.cmaptools.show_cyclic_cmaps(category='All')[source]

Displays all cyclic colormaps in a grid layout.

This function creates a grid of all cyclic colormaps available in matplotlib. The grid is displayed using matplotlib.

Parameters:
  • display (bool, default=False) – If True, display the colormaps as a grid.

  • category (str)

Returns:

Displays the grid of cyclic colormaps using matplotlib

Return type:

None

Examples

>>> show_cyclic_cmaps()  # Display all cyclic colormaps