Python数据可视化 关于cmap颜色函数的试验

color example code: colormaps_reference.py

"""
==================
Colormap reference
==================

Reference for colormaps included with Matplotlib.

This reference example shows all colormaps included with Matplotlib. Note that
any colormap listed here can be reversed by appending "_r" (e.g., "pink_r").
These colormaps are divided into the following categories:

Sequential:
    These colormaps are approximately monochromatic colormaps varying smoothly
    between two color tones---usually from low saturation (e.g. white) to high
    saturation (e.g. a bright blue). Sequential colormaps are ideal for
    representing most scientific data since they show a clear progression from
    low-to-high values.

Diverging:
    These colormaps have a median value (usually light in color) and vary
    smoothly to two different color tones at high and low values. Diverging
    colormaps are ideal when your data has a median value that is significant
    (e.g.  0, such that positive and negative values are represented by
    different colors of the colormap).

Qualitative:
    These colormaps vary rapidly in color. Qualitative colormaps are useful for
    choosing a set of discrete colors. For example::

        color_list = plt.cm.Set3(np.linspace(0, 1, 12))

    gives a list of RGB colors that are good for plotting a series of lines on
    a dark background.

Miscellaneous:
    Colormaps that don't fit into the categories above.

"""
import numpy as np
import matplotlib.pyplot as plt


# Have colormaps separated into categories:
# http://matplotlib.org/examples/color/colormaps_reference.html
cmaps = [('Perceptually Uniform Sequential', [
            'viridis', 'plasma', 'inferno', 'magma']),
         ('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']),
         ('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', 'hsv',
            'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])]


nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps)
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))


def plot_color_gradients(cmap_category, cmap_list, nrows):
    fig, axes = plt.subplots(nrows=nrows)
    fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
    axes[0].set_title(cmap_category + ' colormaps', fontsize=14)

    for ax, name in zip(axes, cmap_list):
        ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name))
        pos = list(ax.get_position().bounds)
        x_text = pos[0] - 0.01
        y_text = pos[1] + pos[3]/2.
        fig.text(x_text, y_text, name, va='center', ha='right', fontsize=10)

    # Turn off *all* ticks & spines, not just the ones with colormaps.
    for ax in axes:
        ax.set_axis_off()


for cmap_category, cmap_list in cmaps:
    plot_color_gradients(cmap_category, cmap_list, nrows)

plt.show()

example

inferno

在这里插入图片描述

viridis

在这里插入图片描述

plasma

在这里插入图片描述

magma

在这里插入图片描述

Blues

在这里插入图片描述

BuGn

在这里插入图片描述

BuPu

在这里插入图片描述

GnBu

在这里插入图片描述

Greens

在这里插入图片描述

Greys

在这里插入图片描述

Oranges

在这里插入图片描述

OrRd

在这里插入图片描述

PuBu

在这里插入图片描述

PuBu

在这里插入图片描述

PuBuGn

在这里插入图片描述

PuRd

在这里插入图片描述

Purples

在这里插入图片描述

RuPu

在这里插入图片描述

Reds

在这里插入图片描述

YlGn

在这里插入图片描述

YlGnBu

在这里插入图片描述

YlOrBr

在这里插入图片描述

YlOrRd

在这里插入图片描述

binary

在这里插入图片描述

spring

在这里插入图片描述

summer

在这里插入图片描述

autumn在这里插入图片描述
winter

在这里插入图片描述

cool

在这里插入图片描述

Wistia

在这里插入图片描述

afmhot

在这里插入图片描述

gist_heat在这里插入图片描述
copper

在这里插入图片描述

PiYG

在这里插入图片描述

PRGn

在这里插入图片描述

BrBG

在这里插入图片描述

coolwarm

在这里插入图片描述

bwr

在这里插入图片描述

seimic

在这里插入图片描述

Pastel1

在这里插入图片描述

Paired

在这里插入图片描述

Accent

在这里插入图片描述

Dark2

在这里插入图片描述

Set1

在这里插入图片描述

Set2

在这里插入图片描述

tab10

在这里插入图片描述

tab20

在这里插入图片描述

tab20b

在这里插入图片描述

flag

在这里插入图片描述

prism

在这里插入图片描述

ocean

在这里插入图片描述

gist_earth

在这里插入图片描述

terrain

在这里插入图片描述

gist_stern

在这里插入图片描述

hsv

在这里插入图片描述

gist_rainbow

在这里插入图片描述

rainbow

在这里插入图片描述

jet

在这里插入图片描述

nipy_spectral

在这里插入图片描述

gist_ncar在这里插入图片描述
cubehelix在这里插入图片描述
brg

在这里插入图片描述

gnuplot2在这里插入图片描述
CMPmap在这里插入图片描述
bone

在这里插入图片描述

pink

在这里插入图片描述

gnuplot

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_44864262/article/details/108483607