matplotlib用Times New Roman且不加粗

将 matplotlib 字体设成 Times New Roman,见 [1,2],但默认是加粗的,想改成加粗,见 [3,4]。例程:

import matplotlib as mpl
mpl.rcParams['text.usetex'] = True

# 换成**不**加粗
import matplotlib.font_manager
del matplotlib.font_manager.weight_dict['roman']
matplotlib.font_manager._rebuild()

# 用 Times New Roman 字体
mpl.rcParams['font.family'] = 'Times New Roman'

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], label='test')

ax.legend()
plt.show()
  • 但是,执行一次之后,就回不去原本加粗的了,注释掉也没用…目前还不知道怎么重置。
  • _rebuild() 的代码,影响的配置文件似乎是 C:\Users\iTom\.matplotlib\ 下的几个 .json 文件。

Rendering

Times New Roman

References

  1. How to set the label Fonts as “Time New Roman” by drawparallels in python
  2. Configuring the font family
  3. Matplotlib: Times New Roman appears bold
  4. Incorrect selection of Times New Roman Bold
  5. matplotlib.font_manager
  6. matplotlib设置宋体和Times New Roman体
  7. Matplotlib中文乱码解决方案(两种方式)
  8. PYTHON MATPLOTLIB 画黑白的柱状图(论文专用)
  9. matplotlib设置中英文多种字体混合坐标轴名称
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值