Matplotlib 代码模版
记录一下自己用 Matplot 画图使用的一些模版代码 全局配置
1 2 3 4 5 6 7 8 9 10 |
# 字体与字号 font = {'family': 'serif', 'serif': 'Times New Roman', 'weight': 'normal', 'size': 10} plt.rc('font', **font) ## 解决某些情况下图中的字体会不正确,见:https://github.com/matplotlib/matplotlib/issues/8017 plt.rc('mathtext', default='regular') # 保存分辨率 plt.rcParams['savefig.dpi'] = 240 plt.rcParams['figure.dpi'] = 240 |
brewer2mpl 配对色 一共12种,共6组颜色(奇数颜色与偶数颜色组成深色与浅色的对比)
1 2 3 4 5 |
# bmap = brewer2mpl.get_map('Paired', 'qualitative', 12) # colors = bmap.mpl_colors colors = [(0.6509803921568628, 0.807843137254902, 0.8901960784313725), (0.12156862745098039, 0.47058823529411764, 0.7058823529411765), (0.6980392156862745, 0.8745098039215686, 0.5411764705882353), (0.2, 0.6274509803921569, 0.17254901960784313), (0.984313725490196, 0.6039215686274509, 0.6), (0.8901960784313725, 0.10196078431372549, 0.10980392156862745), (0.9921568627450981, 0.7490196078431373, 0.43529411764705883), (1.0, 0.4980392156862745, 0.0), (0.792156862745098, 0.6980392156862745, 0.8392156862745098), (0.41568627450980394, 0.23921568627450981, 0.6039215686274509), (1.0, 1.0, 0.6), (0.6941176470588235, 0.34901960784313724, 0.1568627450980392)] |
Pai […]