matplotlib科研绘图---Times New Roman字体设置
matplotlib科研绘图—Times New Roman字体设置
一、法一
plt.figure(figsize=[15,8])
plt.scatter(X, Y, label = 'RealValue')
plt.plot(X, func(X, a, b), 'red', label = 'CurveLine')
plt.title(station, fontdict={'family' : 'Times New Roman', 'size' : 16})
plt.ylabel('Clocks($\mu S$)', fontdict={'family' : 'Times New Roman', 'size' : 16})
plt.xlabel('Time', fontdict={'family' : 'Times New Roman', 'size' : 16})
plt.yticks(fontproperties = 'Times New Roman', size = 14)
plt.xticks(fontproperties = 'Times New Roman', size = 14)
plt.legend(prop={'family' : 'Times New Roman', 'size' : 16})
plt.savefig('./stationClocks/' + station + '.ps', dpi = 200)
plt.show()
二、法二
解决字体不一致的方法
将全局字体改为Times New Roman
import matplotlib.pyplot as plt
plt.rc('font',family='Times New Roman')
del matplotlib.font_manager.weight_dict['roman']
matplotlib.font_manager._rebuild()
三、一些参数
matplotlib说明框中字体粗细
用默认的字体时,'weight’的变化是可以改变字体粗细的,以下是代码
import matplotlib.pyplot as pltstyles=['normal','italic','oblique']
weights=['ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black']
plt.figure(figsize=(15,3))
for i in range(len(styles)):for j in range(len(weights)):font={'style':styles[i],'weight':weights[j]}plt.subplot(len(styles),len(weights),i*len(weights)+j+1) plt.plot([1, 2, 3, 4], [1, 4, 9, 16], 'b', label='VGG-16')plt.legend(loc='upper right', prop=font)
plt.savefig('style.png')
一旦把字体设定为’Times New Roman’,'weight’就没办法调节说明框中字体的粗细
import matplotlib.pyplot as pltstyles=['normal','italic','oblique']
weights=['ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black']
plt.figure(figsize=(15,3))
for i in range(len(styles)):for j in range(len(weights)):font={'family' : 'Times New Roman','style':styles[i],'weight':weights[j]}plt.subplot(len(styles),len(weights),i*len(weights)+j+1) plt.plot([1, 2, 3, 4], [1, 4, 9, 16], 'b', label='VGG-16')plt.legend(loc='upper right', prop=font)
plt.savefig('style.png')
四、Matplotlib画各种论文图
# coding=utf-8import numpy as np
import matplotlib.pyplot as pltplt.rcParams['font.sans-serif'] = ['Arial'] # 如果要显示中文字体,则在此处设为:SimHei
plt.rcParams['axes.unicode_minus'] = False # 显示负号x = np.array([1, 2, 3, 4, 5, 6])
VGG_supervised = np.array([2.9749694, 3.9357018, 4.7440844, 6.482254, 8.720203, 13.687582])
VGG_unsupervised = np.array([2.1044724, 2.9757383, 3.7754183, 5.686206, 8.367847, 14.144531])
ourNetwork = np.array([2.0205495, 2.6509762, 3.1876223, 4.380781, 6.004548, 9.9298])# label在图示(legend)中显示。若为数学公式,则最好在字符串前后添加"$"符号
# color:b:blue、g:green、r:red、c:cyan、m:magenta、y:yellow、k:black、w:white、、、
# 线型:- -- -. : ,
# marker:. , o v < * + 1
plt.figure(figsize=(10, 5))
plt.grid(linestyle="--") # 设置背景网格线为虚线
ax = plt.gca()
ax.spines['top'].set_visible(False) # 去掉上边框
ax.spines['right'].set_visible(False) # 去掉右边框plt.plot(x, VGG_supervised, marker='o', color="blue", label="VGG-style Supervised Network", linewidth=1.5)
plt.plot(x, VGG_unsupervised, marker='o', color="green", label="VGG-style Unsupervised Network", linewidth=1.5)
plt.plot(x, ourNetwork, marker='o', color="red", label="ShuffleNet-style Network", linewidth=1.5)group_labels = ['Top 0-5%', 'Top 5-10%', 'Top 10-20%', 'Top 20-50%', 'Top 50-70%', ' Top 70-100%'] # x轴刻度的标识
plt.xticks(x, group_labels, fontsize=12, fontweight='bold') # 默认字体大小为10
plt.yticks(fontsize=12, fontweight='bold')
# plt.title("example", fontsize=12, fontweight='bold') # 默认字体大小为12
plt.xlabel("Performance Percentile", fontsize=13, fontweight='bold')
plt.ylabel("4pt-Homography RMSE", fontsize=13, fontweight='bold')
plt.xlim(0.9, 6.1) # 设置x轴的范围
plt.ylim(1.5, 16)# plt.legend() #显示各曲线的图例
plt.legend(loc=0, numpoints=1)
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize=12, fontweight='bold') # 设置图例字体的大小和粗细plt.savefig('./filename.svg', format='svg') # 建议保存为svg格式,再用inkscape转为矢量图emf后插入word中
plt.show()
matplotlib科研绘图---Times New Roman字体设置相关推荐
- Matplotlib进行绘图
文章最前: 我是Octopus,这个名字来源于我的中文名--章鱼:我热爱编程.热爱算法.热爱开源.所有源码在我的个人github :这博客是记录我学习的点点滴滴,如果您对 Python.Java.AI ...
- 科研绘图(Matplotlib.pyplot)
本文为目标导向,目标就是利用Matplotlib绘制类似于下图的多子图.图例位于坐标轴外且格式为矢量图的论文插图. 利用Matplotlib库绘图的推荐路线: 首先根据需求搜索所需函数: 之后直接根据 ...
- matplotlib的默认字体_浅谈matplotlib默认字体设置探索
控制默认字体的设置 根据官方文档https://matplotlib.org/tutorials/text/text_props.html#default-font可知: The base defau ...
- matplotlib默认字体设置探索
控制默认字体的设置 根据官方文档https://matplotlib.org/tutorials/text/text_props.html#default-font可知: The base defau ...
- Python利用Matplotlib绘图无法显示中文字体的解决方案
这里写目录标题 问题描述 报错信息 解决方法 其他解决方案 使用模板(内置样式)后无法显示中文的解决方案 问题描述 在Python利用Matplotlib绘图的时候,无法显示坐标轴上面的中文和标题里面 ...
- 用matplotlib绘制带误差的条形图及中英文字体设置
1 #!/usr/bin/env python3 2 3 ## 以下是一个带误差条的条形图的例子,演示了误差条形图的绘制及中英文字体设置 4 import numpy as np 5 import m ...
- python matplotlib 画图 不显示中文 中文乱码 设置中文字体
在使用python matplotlib 画图时,由于matplotlib 默认是使用DejaVu Sans这种字体,不支持中文,所以我们在使用matplotlib画图包含中文内容要显示时就会变成方框 ...
- word 使用 aurora 插入公式,设置 Times New Roman 字体遇到的几个问题、以及解决方案
本文要解决的问题:在word使用aurora插入latex编写的公式,公式字体设置 Times New Roman. 前言 由于必须使用 word 写论文,不想用mathtype,想用latex语言来 ...
- 如何修改matplotlib字体?(matplotlib字体设置)
参考资料: https://matplotlib.org/stable/api/text_api.html?highlight=text#matplotlib.text.Text https://ma ...
- JAVA学习绘图颜色及其笔画属性设置字体显示文字
package com.graphics;import java.awt.*; import java.awt.geom.Rectangle2D; import java.util.Date;impo ...
最新文章
- logback-spring.xml读取spring的属性
- 服务器收到消息怎么推送给app_「刹那问答24」浅谈FCM推送
- mysql工具使用意义_MySQL性能分析、及调优工具使用详解
- Mysql错误代码大全
- 《编译原理》第三章知识点
- JAVA数据类型及字符编码
- 26、jdbc操作数据库(3)
- vue 父组件与子组件之间的传值(普通传值)
- 酒店三合一终端服务器,【MOXA NPort6650-8八口三合一信号安全终端服务器价格_MOXA NPort6650-8八口三合一信号安全终端服务器厂家】- 网络114...
- html是一种描述的沙子语言,小学低年级语文阅读训练
- Android Studio升级到3.0,抛出Aapt2Exception异常
- ios模拟器安装app
- 制作简易的幸运转盘抽奖
- VS2017生成可执行程序,执行提示“不是有效的win32应用程序”
- linux开发板2048游戏界面图,linux c 实现2048游戏
- 专业档案门类代码编码方案
- 那些年啊,那些事——一个程序员的奋斗史 ——39
- 谁对云服务器安全负责:客户还是供应商 ?
- 深度学习 英文 训练阶段_深度学习英语单词才是王道丨6步就搞定!
- linux 软件包的安装,linux安装软件包的方法
热门文章
- tp810c桥接_TP-Link双无线路由器开启WDS桥接设置步骤
- Jest测试框架入门之快照测试(附踩坑指南)
- 论文学习笔记:Detecting and quantifying causal associations in large nonlinear time series datasets
- element中navMenu结合路由使用
- Java实现图片上传到服务器,并把上传的图片读取出来
- 空间命名的定义及使用:using namespace std 的用法详解
- cad审图软件lisp_CAD审图软件下载_小智审图(建筑行业智能助手) 3.3.1 个人版_极速下载站_软件下载...
- 百度地图 根据经纬度获取 地址
- Swift-Moya 源码解析
- nginx域名反向代理