❞
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生物人”