.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/color/colormap_reference.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_color_colormap_reference.py: ================== Colormap reference ================== Reference for colormaps included with Matplotlib. A reversed version of each of these colormaps is available by appending ``_r`` to the name, as shown in :ref:`reverse-cmap`. See :ref:`colormaps` for an in-depth discussion about colormaps, including colorblind-friendliness, and :ref:`colormap-manipulation` for a guide to creating colormaps. .. GENERATED FROM PYTHON SOURCE LINES 16-71 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np cmaps = [('Perceptually Uniform Sequential', [ 'viridis', 'plasma', 'inferno', 'magma', 'cividis']), ('Sequential', [ 'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']), ('Sequential (2)', [ 'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper']), ('Diverging', [ 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']), ('Cyclic', ['twilight', 'twilight_shifted', 'hsv']), ('Qualitative', [ 'Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']), ('Miscellaneous', [ 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral', 'gist_ncar'])] gradient = np.linspace(0, 1, 256) gradient = np.vstack((gradient, gradient)) def plot_color_gradients(cmap_category, cmap_list): # Create figure and adjust figure height to number of colormaps nrows = len(cmap_list) figh = 0.35 + 0.15 + (nrows + (nrows-1)*0.1)*0.22 fig, axs = plt.subplots(nrows=nrows, figsize=(6.4, figh)) fig.subplots_adjust(top=1-.35/figh, bottom=.15/figh, left=0.2, right=0.99) axs[0].set_title(f"{cmap_category} colormaps", fontsize=14) for ax, cmap_name in zip(axs, cmap_list): ax.imshow(gradient, aspect='auto', cmap=cmap_name) ax.text(-.01, .5, cmap_name, va='center', ha='right', fontsize=10, transform=ax.transAxes) # Turn off *all* ticks & spines, not just the ones with colormaps. for ax in axs: ax.set_axis_off() for cmap_category, cmap_list in cmaps: plot_color_gradients(cmap_category, cmap_list) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_001.png :alt: Perceptually Uniform Sequential colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_001.png, /gallery/color/images/sphx_glr_colormap_reference_001_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_002.png :alt: Sequential colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_002.png, /gallery/color/images/sphx_glr_colormap_reference_002_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_003.png :alt: Sequential (2) colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_003.png, /gallery/color/images/sphx_glr_colormap_reference_003_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_004.png :alt: Diverging colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_004.png, /gallery/color/images/sphx_glr_colormap_reference_004_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_005.png :alt: Cyclic colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_005.png, /gallery/color/images/sphx_glr_colormap_reference_005_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_006.png :alt: Qualitative colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_006.png, /gallery/color/images/sphx_glr_colormap_reference_006_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_007.png :alt: Miscellaneous colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_007.png, /gallery/color/images/sphx_glr_colormap_reference_007_2_00x.png 2.00x :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 72-79 .. _reverse-cmap: Reversed colormaps ------------------ Append ``_r`` to the name of any built-in colormap to get the reversed version: .. GENERATED FROM PYTHON SOURCE LINES 79-82 .. code-block:: Python plot_color_gradients("Original and reversed ", ['viridis', 'viridis_r']) .. image-sg:: /gallery/color/images/sphx_glr_colormap_reference_008.png :alt: Original and reversed colormaps :srcset: /gallery/color/images/sphx_glr_colormap_reference_008.png, /gallery/color/images/sphx_glr_colormap_reference_008_2_00x.png 2.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 83-85 The built-in reversed colormaps are generated using `.Colormap.reversed`. For an example, see :ref:`reversing-colormap` .. GENERATED FROM PYTHON SOURCE LINES 87-96 .. admonition:: References The use of the following functions, methods, classes and modules is shown in this example: - `matplotlib.colors` - `matplotlib.axes.Axes.imshow` - `matplotlib.figure.Figure.text` - `matplotlib.axes.Axes.set_axis_off` .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.952 seconds) .. _sphx_glr_download_gallery_color_colormap_reference.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: colormap_reference.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: colormap_reference.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_