当前位置:网站首页>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) #下边
参考
边栏推荐
- 小程序项目结构
- Applet page navigation
- Kubernetes resource object introduction and common commands (V) - (configmap & Secret)
- [record of question brushing] 1 Sum of two numbers
- 信息学奥赛一本通 1340:【例3-5】扩展二叉树
- 科普|英语不好对NPDP考试有影响吗 ?
- 手机开户股票开户安全吗?我家比较偏远,有更好的开户途径么?
- Station B up builds the world's first pure red stone neural network, pornographic detection based on deep learning action recognition, Chen Tianqi's course progress of machine science compilation MLC,
- 全国爱眼教育大会,2022第四届北京国际青少年眼健康产业展会
- 14、Transformer--VIT TNT BETR
猜你喜欢

CTF逆向基础

Classic implementation method of Hongmeng system controlling LED

全国爱眼教育大会,2022第四届北京国际青少年眼健康产业展会

Duchefa MS medium contains vitamin instructions

CADD course learning (7) -- Simulation of target and small molecule interaction (semi flexible docking autodock)

Hongmeng OS' fourth learning
![[quick start of Digital IC Verification] 2. Through an example of SOC project, understand the architecture of SOC and explore the design process of digital system](/img/1d/22bf47bfa30b9bdc2e8fd348180f49.png)
[quick start of Digital IC Verification] 2. Through an example of SOC project, understand the architecture of SOC and explore the design process of digital system

2.8 basic knowledge of project management process

Enter the parallel world

Make Jar, Not War
随机推荐
Minimum commission for stock trading account opening, where to open an account with low commission? Is it safe to open an account on your mobile phone
培养机器人教育创造力的前沿科技
Mongodb basic exercises
2022 Beijing eye health products exhibition, eye care products exhibition, China eye Expo held in November
19 mongoose modularization
资源道具化
Abnova丨CRISPR SpCas9 多克隆抗体方案
Schema and model
Applet global configuration
信息学奥赛一本通 1339:【例3-4】求后序遍历 | 洛谷 P1827 [USACO3.4] 美国血统 American Heritage
Classic implementation of the basic method of intelligent home of Internet of things
[quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives
Applet event binding
Duchefa丨D5124 MD5A 培养基中英文说明书
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
Informatics Orsay all in one 1339: [example 3-4] find the post order traversal | Valley p1827 [usaco3.4] American Heritage
Abnova 环孢素A单克隆抗体,及其研究工具
Hongmeng OS' fourth learning
Abnova丨培养细胞总 RNA 纯化试剂盒中英文说明书
台风来袭!建筑工地该如何防范台风!