首页 > 其他 > 详细

matplotlib 中的 colors 和 cmaps

时间:2019-12-14 19:26:12      阅读:1235      评论:0      收藏:0      [点我收藏+]

matplotlib 中的 148 种颜色

matplotlib 中的 160 种颜色映射

 

1、matplotlib中的 148 种颜色

import matplotlib as plm
import matplotlib.pyplot as plt

colors = plm.colors.cnames.keys()

fig = plt.figure(百里希文, facecolor=lightyellow, edgecolor=k)
axes = fig.subplots(len(colors)//4, 4)

for c, ax in zip(colors, axes.ravel()):
    ax.hist(1, 3, color=c)
    ax.text(1.2, 0.1, c)
    ax.set_axis_off()
fig.subplots_adjust(left
=0, bottom=0, right=0.9, top=1, hspace=0.1, wspace=0.1)
fig.show()

 

技术分享图片

 

2 matplotlib 中的 160 种颜色映射

import numpy as npimport matplotlib as plm
import matplotlib.pyplot as plt

cmaps = plm.cm.cmap_d.keys()
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))  

fig = plt.figure(百里希文, facecolor=lightyellow, edgecolor=k)
axes = fig.subplots(len(cmaps)//5, 5)

for cmap, ax in zip(cmaps, axes.ravel()):
    ax.imshow(gradient, aspect=auto, cmap=plt.get_cmap(cmap))
    ax.text(100, 1, cmap, fontsize=14)
    ax.set_axis_off()
    
fig.subplots_adjust(left=0.1, bottom=0, right=0.9,
                    top=1, hspace=0.1, wspace=0.1)    
fig.show()

技术分享图片

 

 

按语:

推荐几篇文章

https://cloud.tencent.com/developer/ask/136207/answer/241390

https://blog.csdn.net/Mr_Cat123/article/details/78638491

https://www.cnblogs.com/charliedaifu/p/9957822.html

https://blog.csdn.net/zhaogeng111/article/details/78419015

matplotlib 中的 colors 和 cmaps

原文:https://www.cnblogs.com/shanger/p/12040545.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!