颜色映射

一个绘制 matplotlib 颜色映射的示例。

Accent, Blues, BrBG, BuGn, BuPu, CMRmap, Dark2, GnBu, Grays, Greens, Greys, OrRd, Oranges, PRGn, Paired, Pastel1, Pastel2, PiYG, PuBu, PuBuGn, PuOr, PuRd, Purples, RdBu, RdGy, RdPu, RdYlBu, RdYlGn, Reds, Set1, Set2, Set3, Spectral, Wistia, YlGn, YlGnBu, YlOrBr, YlOrRd, afmhot, autumn, binary, bone, brg, bwr, cividis, cool, coolwarm, copper, cubehelix, flag, gist_earth, gist_gray, gist_grey, gist_heat, gist_ncar, gist_rainbow, gist_stern, gist_yarg, gist_yerg, gnuplot, gnuplot2, gray, grey, hot, hsv, inferno, jet, magma, nipy_spectral, ocean, pink, plasma, prism, rainbow, seismic, spring, summer, tab10, tab20, tab20b, tab20c, terrain, turbo, twilight, twilight_shifted, viridis, winter
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
plt.rc("text", usetex=False)
a = np.outer(np.arange(0, 1, 0.01), np.ones(10))
plt.figure(figsize=(10, 5))
plt.subplots_adjust(top=0.8, bottom=0.05, left=0.01, right=0.99)
maps = [m for m in matplotlib.colormaps if not m.endswith("_r")]
maps.sort()
l = len(maps) + 1
for i, m in enumerate(maps):
plt.subplot(1, l, i + 1)
plt.axis("off")
plt.imshow(a, aspect="auto", cmap=plt.get_cmap(m), origin="lower")
plt.title(m, rotation=90, fontsize=10, va="bottom")
plt.show()

脚本总运行时间:(0 分钟 1.781 秒)

由 Sphinx-Gallery 生成的图库