Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib setting title bold while using "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")

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?

like image 577
wdg Avatar asked Sep 23 '13 14:09

wdg


People also ask

How do I change the font size on a Matplotlib label?

The size and font of title and axes in Matplotlib can be set by adjusting fontsize parameter, using set_size() method, and changing values of rcParams dictionary.

What is the function of PLT title () method in Matplotlib?

The title() method in matplotlib module is used to specify title of the visualization depicted and displays the title using various attributes.


1 Answers

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']
like image 190
askewchan Avatar answered Oct 12 '22 23:10

askewchan