最初我可以通过以下方式将图形标题设置为粗体:
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/