Matplotlib在使用"Times New Roman"时将标题设置为粗体 [英] Matplotlib setting title bold while using "Times New Roman"
本文介绍了Matplotlib在使用"Times New Roman"时将标题设置为粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最初我可以通过以下方式将图形标题设置为粗体:
Originally I can set the figure title to bold by the following:
import Matplotlib.pyplot as plt
plt.title("Test",fontweight="bold")
但是一旦我使用 fontname="Times New Roman"
,fontweight="bold"
根本不会导致任何变化:
but once I use fontname="Times New Roman"
, fontweight="bold"
just won't result in any change at all:
import Matplotlib.pyplot as plt
plt.title("Test",fontname="Times New Roman",fontweight="bold")
如何将图形标题设置为粗体?
How shall I set the figure title to bold?
推荐答案
假设您的系统上安装了它自己的粗体时代字体:
There's a bold times font of its own, assuming it's installed on your system:
plt.title("Test", fontname="Times New Roman Bold")
您可以在此处找到系统上的字体列表:如何获取Matplotlib当前可用的所有字体的列表?/a>
You can find a list of fonts on your system here: 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']
这篇关于Matplotlib在使用"Times New Roman"时将标题设置为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文