matplotlibで使える色一覧
色一覧
画像作成プログラム
import matplotlib import colorsys import matplotlib.pyplot as plt from matplotlib import rcParams rcParams['font.family'] = 'Ricty Diminished' def penc(hval): r=int(hval[1:3],16) g=int(hval[3:5],16) b=int(hval[6:8],16) hsv=colorsys.rgb_to_hsv(r/255, g/255, b/255) h=hsv[0] s=hsv[1] v=hsv[2] col='#000000' if 0.5<h: col='#ffffff' if v<0.75: col='#ffffff' return col cdic=matplotlib.colors.cnames lkey=[] lval=[] for key, val in zip(cdic.keys(), cdic.values()): lkey=lkey+[key] lval=lval+[val] xmin=0 xmax=4 k=-1 fnameF='fig_col_mpl.png' ymin=0 ymax=37 plt.figure(figsize=(6,12)) plt.xlim([xmin,xmax]) plt.ylim([ymax,ymin]) plt.axis('off') fsize=8 # fontsize k=-1 for i in range(int(ymin),int(ymax)): for j in range(0,4): k=k+1 if k<len(lval): xs=float(j) xe=xs+1.0 ys=float(i) ye=ys+1.0 xx=[xs,xe,xe,xs] yy=[ys,ys,ye,ye] plt.fill(xx,yy,color=lval[k]) text1=lkey[k] text2=lval[k] xg=0.5*(xs+xe) yg=0.5*(ys+ye) col=penc(lval[k]) plt.text(xg,yg-0.25,text1,rotation=0,ha='center',va='center',fontsize=fsize,color=col) plt.text(xg,yg+0.25,text2,rotation=0,ha='center',va='center',fontsize=fsize,color=col) plt.savefig(fnameF, dpi=300, bbox_inches="tight", pad_inches=0)
以 上