color对照 python_Python爬取nipponcolors并制作色值Cheat sheet

nipponcolors简介

nipponcolors由下面这个甩锅开发

网站上罗列了日本传统色彩「250种」,非常绚丽,上图上图。。。。。

nipponcolors爬虫

过程略,结果为一个json文件:nipponcolor.json,结构如下图。

nipponcolors 色值Cheat sheet读入nipponcolor.json

import json

colist = []

with open('nipponcolor.json',encoding='UTF-8') as f:

colist = json.load(f)

cnamel = []

colorl = []

for i in colist:

cnamel.append(i['cname'])

colorl.append(i['color'])

print(cnamel)

print(colorl)

print(len(colorl))python imshow绘图

import numpy as np

import matplotlib

import matplotlib.pyplot as plt

from matplotlib.colors import ListedColormap

plt.rcParams['font.sans-serif']=['SimHei']

plt.rcParams['axes.unicode_minus'] = False

position = np.arange(250).reshape(25,10)

colname = np.array(cnamel).reshape(25,10)

colname_hex = np.array(colorl).reshape(25,10)

cmp1 = ListedColormap(colorl)

fig, ax = plt.subplots(dpi=1000)

m = ax.imshow(position,cmap=cmp1,interpolation='none')

# x轴刻度标签设置

plt.setp(ax.get_xticklabels(), rotation=45, ha="right",rotation_mode="anchor")

# 文字、色值显示在格子中

for i in range(25):

for j in range(10):

text = ax.text(j, i,

colname[i, j]+'\n'+colname_hex[i,j],

ha="center", va="center", color="black",fontsize=2)

for i in ['top','right','left','bottom']:

plt.gca().spines[i].set_visible(False)

plt.show()

赶快收起来,偷偷使用吧~~~

欢迎关注:公众号“pythonic生物人”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值