1 Star 0 Fork 1

niceb/matplotlib-cheatsheet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
reference-colormap-sequential-2.py 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
# ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: BSD
# ----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
cmaps = ('bone', 'gray', 'pink', 'afmhot', 'hot', 'gist_heat', 'copper',
'Wistia', 'autumn_r', 'summer_r', 'spring_r', 'cool', 'winter_r')
n = len(cmaps)
fig = plt.figure(figsize=(4.25, n*.22))
ax = plt.subplot(1, 1, 1, frameon=False,
xlim=[0,10], xticks=[], yticks=[])
fig.subplots_adjust(top=0.99, bottom=0.01, left=0.15, right=0.99)
y, dy, pad = 0, 0.5, 0.1
ticks, labels = [], []
for cmap in cmaps[::-1]:
Z = np.linspace(0,1,512).reshape(1,512)
plt.imshow(Z, extent=[0,10,y,y+dy], cmap=plt.get_cmap(cmap))
ticks.append(y+dy/2)
labels.append(cmap)
y = y + dy + pad
ax.set_ylim(-pad,y)
ax.set_yticks(ticks)
ax.set_yticklabels(labels)
ax.tick_params(axis='y', which='both', length=0, labelsize="small")
plt.savefig("reference-colormap-sequential-2.pdf", dpi=600)
plt.show()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/niceb2/matplotlib-cheatsheet.git
[email protected]:niceb2/matplotlib-cheatsheet.git
niceb2
matplotlib-cheatsheet
matplotlib-cheatsheet
master

搜索帮助