最初我可以通过以下方式将图标题设置为粗体:
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)
如何将图标题设置为粗体?
假设它已安装在您的系统上,它有一个大胆的时间字体:
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)