python - Matplotlib 在使用 "Times New Roman"时设置粗体标题

标签 python matplotlib

最初我可以通过以下方式将图形标题设置为粗体:

import Matplotlib.pyplot as plt

plt.title("Test",fontweight="bold")

但是一旦我使用 fontname="Times New Roman"fontweight="bold" 根本不会导致任何更改:

import Matplotlib.pyplot as plt

plt.title("Test",fontname="Times New Roman",fontweight="bold")

如何将图标题设置为粗体?

最佳答案

假设您的系统上安装了它自己的粗体字体:

plt.title("Test", fontname="Times New Roman Bold")

您可以在此处找到系统上的字体列表:How to get a list of all the fonts currently available for Matplotlib?

我有:

>>> [i for i in matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
if 'times' in i.lower()]
['/Library/Fonts/Times New Roman.ttf',
 '/Library/Fonts/Times New Roman Italic.ttf',
 '/Library/Fonts/Times New Roman Bold Italic.ttf',
 '/Library/Fonts/Times New Roman Bold.ttf']

关于python - Matplotlib 在使用 "Times New Roman"时设置粗体标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18962063/

相关文章:

python - Django Rest Framework-可写嵌套序列化器错误

python - 如何绘制非数值数据的日期时间和 value_counts() ?

python - 在 Python 中提取图像的外部轮廓或剪影

python - 绘图 : single legend when plotting on secondary y-axis

python - 从具有 CloudFlare 的网站中抓取(BeautifulSoup,请求)

python - 打印值的pythonic方式

python - 如何计算出 GridSearchCV 将训练多少个模型?

python - 如何在 seaborn lineplot 上绘制虚线?

python - 将文本标记标签添加到 pcolor 热图

python - Wagtail:如何将按钮 "add subpage"添加到自定义 ListView (IndexView) 的操作列表中?