Matplotlib setting title bold while using “Times New Roman”

前端 未结 3 662
野的像风
野的像风 2021-01-04 05:48

Originally I can set the figure title to bold by the following:

import Matplotlib.pyplot as plt

plt.title(\"Test\",fontweight=\"bold\")

bu

3条回答
  •  隐瞒了意图╮
    2021-01-04 06:50

    There's a bold times font of its own, assuming it's installed on your system:

    plt.title("Test", fontname="Times New Roman Bold")
    

    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 have:

    >>> [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']
    

提交回复
热议问题