gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:03:33 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com