当前位置:网站首页>matplotlib绘图润色(如何形成高质量的图,例如设如何置字体等)
matplotlib绘图润色(如何形成高质量的图,例如设如何置字体等)
2022-07-05 20:38:00 【音程】
前言
本来,如果只是你自己画图然后自己一个人偷着看看,一般是没有这个需求的,直接默认就好了。
然而,如果你要把这个图印刷出版,或者放在论文中,或者放在PPT中展示。你会发现,默认的图不太行。比如放在论文中,如果默认的话,里面的字体会特别模糊。
import matplotlib.pyplot as plt
分辨率
在开头加上下面这句,可以使得你的图片不会模糊。
plt.figure(dpi=300)
样式
样式包括很多方便,字体大小,字体格式等。
1.先说一个全局改变的,也就是说开头加上,然后全局有效,很方便。
plt.rcParams["font.weight"] = "bold"
plt.rcParams["axes.labelweight"] = "bold"
2.然后再局部改变的。
# 修改标题及x,y坐标轴字体及大小
plt.title("$MFCC_0$参数中值滤波", fontsize=15,fontweight='bold')
plt.xlabel("时间/s", fontsize=15,fontweight='bold')
plt.ylabel("数值", fontsize=15,fontweight='bold')
# 修改坐标轴字体及大小
plt.yticks(fontproperties='Times New Roman', size=15,weight='bold')#设置大小及加粗
plt.xticks(fontproperties='Times New Roman', size=15)
# 设置标题
plt.rcParams['font.sans-serif'] = ['KaiTi'] # 用来正常显示中文标签,如果想要用新罗马字体,改成 Times New Roman
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
plt.tight_layout() # 解决绘图时上下标题重叠现象
#画线
plt.vlines(starts2time, min(Mfcc1)-10, max(Mfcc1)+10, colors="black", linestyles="solid",lw=2)
plt.vlines(ends2time, min(Mfcc1)-10, max(Mfcc1)+10, colors="black", linestyles="dashed",lw=2.5)
#添加图例
plt.legend(['train acc','train loss'])#添加图例
plt.legend(['train acc','train loss'],fontsize=12)#并且设置大小
#取消坐标轴刻度
plt.xticks([]) # 去x坐标刻度
plt.yticks([]) # 去y坐标刻度
plt.axis('off') # 去坐标轴
#取消savefig保存图片时的白色边框
plt.savefig(pic_name,bbox_inches='tight',pad_inches=0.0)
#取消每一个的边框
ax1 = plt.subplot(2, 3, 1)
ax1.spines['right'].set_visible(False) #右边
ax1.spines['top'].set_visible(False) #上边
ax1.spines['left'].set_visible(False) #左边
ax1.spines['bottom'].set_visible(False) #下边
参考
边栏推荐
- 小程序全局配置
- Oracle tablespace management
- [record of question brushing] 1 Sum of two numbers
- 如何让化工企业的ERP库存账目更准确
- 中国管理科学研究院凝聚行业专家,傅强荣获智库专家“十佳青年”称号
- [UE4] unrealinsight obtains the real machine performance test report
- E. Singhal and numbers (prime factor decomposition)
- Abnova丨E (DIII) (WNV) 重组蛋白 中英文说明书
- CCPC 2021 Weihai - G. shinyruo and KFC (combination number, tips)
- Abnova丨CRISPR SpCas9 多克隆抗体方案
猜你喜欢
随机推荐
资源道具化
2020 CCPC Weihai - A. golden spirit (thinking), D. ABC project (big number decomposition / thinking)
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
NPDP如何续证?操作指南来了!
Simple understanding of interpolation search
物联网智能家居基本方法实现之经典
Codeforces Round #804 (Div. 2) - A, B, C
July 4, 2022 - July 10, 2022 (UE4 video tutorial MySQL)
mongodb/文档操作
王老吉药业“关爱烈日下最可爱的人”公益活动在南京启动
Where is a good stock account? Is online account manager safe to open an account
Pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs
2.8、项目管理过程基础知识
Applet page navigation
表单文本框的使用(二) 输入过滤(合成事件)
小程序项目结构
Duchefa丨MS培养基含维生素说明书
基础篇——配置文件解析
Mongodb/ document operation
The Chinese Academy of Management Sciences gathered industry experts, and Fu Qiang won the title of "top ten youth" of think tank experts









