pycharmers.matplotlib.cmaps module

pycharmers.matplotlib.cmaps.plot_color_palettes(palette_name='all')[source]

Plot color palettes

Parameters

palette_name (str) – The name of a color map known to matplotlib

Example

>>> from pycharmers.matplotlib import plot_color_palettes
>>> # plot specified color map
>>> plot_color_palettes(palette_name="xkcd")
>>> # plot All color maps
>>> plot_color_palettes(palette_name="all")
pycharmers.matplotlib.cmaps.plot_cmap_samples(cmap_name='all', ax=None, dpi=10)[source]

Plot color map samples

Parameters
  • cmap_name (str) – The name of a color map known to matplotlib

  • ax (Axes) – The Axes instance.

  • dpi (int) – The resolution of the figure. (The size of matrix.)

Example

>>> from pycharmers.matplotlib import plot_cmap_samples
>>> # plot specified color map
>>> ax = plot_cmap_samples(cmap_name="jet")
>>> # plot All color maps
>>> plot_cmap_samples(cmap_name="all")
>>> # plot color map with different dpi (Dots per inch)
>>> ax = plot_cmap_samples(cmap_name="Pastel1", dpi=9)
pycharmers.matplotlib.cmaps.plot_cmap_category_samples(category='all')[source]

Plot all colormap samples in a category

Parameters

category (str) – the name of a color map category.

Example

>>> from pycharmers.matplotlib import plot_cmap_samples
>>> # plot specified color map category
>>> plot_cmap_category_samples(category="Sequential")
>>> # plot All color map categories
>>> plot_cmap_category_samples(category="all")
pycharmers.matplotlib.cmaps.color_dict_create(keys, cmap='jet', reverse=False, max_val=1)[source]

Create a color dict.

Parameters
  • keys (int / list) – (The number of) Keys of the color dict

  • cmap (str / matplotlib.colors) – Color map.

  • reverse (bool) – Whether to reverse the color.

  • max_val (int) – Max value of color code.

Returns

key -> color.

Return type

color_dict

Examples

>>> import matplotlib.pyplot as plt
>>> from pycharmers.matplotlib import color_dict_create
>>> color_dict_create(keys=["a","b","c"], cmap="jet")
{
    'b': (0.0, 0.0, 0.5, 1.0),
    'c': (0.4901960784313725, 1.0, 0.4775458570524984, 1.0),
    'a': (0.5, 0.0, 0.0, 1.0)
}
>>> color_dict_create(keys=3, cmap="jet")
{
    0: (0.0, 0.0, 0.5, 1.0),
    1: (0.4901960784313725, 1.0, 0.4775458570524984, 1.0),
    2: (0.5, 0.0, 0.0, 1.0)
}
>>> color_dict_create(keys=["a","b","c"], cmap=plt.get_cmap("jet"))
{
    'b': (0.0, 0.0, 0.5, 1.0),
    'c': (0.4901960784313725, 1.0, 0.4775458570524984, 1.0),
    'a': (0.5, 0.0, 0.0, 1.0)
}