{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Colormap reference\n\nReference for colormaps included with Matplotlib.\n\nA reversed version of each of these colormaps is available by appending\n``_r`` to the name, as shown in `reverse-cmap`.\n\nSee `colormaps` for an in-depth discussion about\ncolormaps, including colorblind-friendliness, and\n`colormap-manipulation` for a guide to creating\ncolormaps.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\ncmaps = [('Perceptually Uniform Sequential', [\n            'viridis', 'plasma', 'inferno', 'magma', 'cividis']),\n         ('Sequential', [\n            'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',\n            'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',\n            'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']),\n         ('Sequential (2)', [\n            'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter',\n            'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper']),\n         ('Diverging', [\n            'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',\n            'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic',\n            'berlin', 'managua', 'vanimo']),\n         ('Cyclic', ['twilight', 'twilight_shifted', 'hsv']),\n         ('Qualitative', [\n            'Pastel1', 'Pastel2', 'Paired', 'Accent', 'okabe_ito',\n            'Dark2', 'Set1', 'Set2', 'Set3',\n            'tab10', 'tab20', 'tab20b', 'tab20c']),\n         ('Miscellaneous', [\n            'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',\n            'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',\n            'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',\n            'gist_ncar'])]\n\ngradient = np.linspace(0, 1, 256)\ngradient = np.vstack((gradient, gradient))\n\n\ndef plot_color_gradients(cmap_category, cmap_list):\n    # Create figure and adjust figure height to number of colormaps\n    nrows = len(cmap_list)\n    figh = 0.35 + 0.15 + (nrows + (nrows-1)*0.1)*0.22\n    fig, axs = plt.subplots(nrows=nrows, figsize=(6.4, figh))\n    fig.subplots_adjust(top=1-.35/figh, bottom=.15/figh, left=0.2, right=0.99)\n\n    axs[0].set_title(f\"{cmap_category} colormaps\", fontsize=14)\n\n    for ax, cmap_name in zip(axs, cmap_list):\n        ax.imshow(gradient, aspect='auto', cmap=cmap_name)\n        ax.text(-.01, .5, cmap_name, va='center', ha='right', fontsize=10,\n                transform=ax.transAxes)\n\n    # Turn off *all* ticks & spines, not just the ones with colormaps.\n    for ax in axs:\n        ax.set_axis_off()\n\n\nfor cmap_category, cmap_list in cmaps:\n    plot_color_gradients(cmap_category, cmap_list)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: Discouraged\n\n   For backward compatibility we additionally support the following colormap\n   names, which are identical to other builtin colormaps. Their use is\n   discouraged. Use the suggested replacement instead.\n\n   =========  =================================\n   Colormap   Use identical replacement instead\n   =========  =================================\n   gist_gray \tgray\n   gist_yarg \tgray_r\n   binary \tgray_r\n   =========  =================================\n\n\n\n## Reversed colormaps\n\nAppend ``_r`` to the name of any built-in colormap to get the reversed\nversion:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plot_color_gradients(\"Original and reversed \", ['viridis', 'viridis_r'])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The built-in reversed colormaps are generated using `.Colormap.reversed`.\nFor an example, see `reversing-colormap`\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.colors`\n   - `matplotlib.axes.Axes.imshow`\n   - `matplotlib.figure.Figure.text`\n   - `matplotlib.axes.Axes.set_axis_off`\n\n.. tags::\n\n   styling: colormap\n   purpose: reference\n\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}