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

wdg*_*wdg 8 python matplotlib

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

import Matplotlib.pyplot as plt

plt.title("Test",fontweight="bold")
Run Code Online (Sandbox Code Playgroud)

但是一旦我使用fontname="Times New Roman",fontweight="bold"就不会导致任何改变:

import Matplotlib.pyplot as plt

plt.title("Test",fontname="Times New Roman",fontweight="bold")
Run Code Online (Sandbox Code Playgroud)

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

Nik*_*hil 17

fontweight 是Fig.suptitle() 函数的参数。所以这应该对你有用, fig.suptitle("Test",fontweight='bold')


ask*_*han 6

假设它已安装在您的系统上,它有一个大胆的时间字体:

plt.title("Test", fontname="Times New Roman Bold")
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到系统中的字体列表:如何获取当前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']
Run Code Online (Sandbox Code Playgroud)