Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bold font weight for LaTeX axes label in matplotlib

In matplotlib you can make the text of an axis label bold by

plt.xlabel('foo',fontweight='bold') 

You can also use LaTeX with the right backend

plt.xlabel(r'$\phi$') 

When you combine them however, the math text is not bold anymore

plt.xlabel(r'$\phi$',fontweight='bold') 

Nor do the following LaTeX commands seem to have any effect

plt.xlabel(r'$\bf \phi$') plt.xlabel(r'$\mathbf{\phi}$') 

How can I make a bold $\phi$ in my axis label?

like image 923
Hooked Avatar asked Jan 14 '13 18:01

Hooked


People also ask

How do I make axis labels bold in Matplotlib?

Matplotlib x-axis label boldPass the fontweight parameter to the xlabel() function to make the label bold.

How do I label the bold axis?

Make Axis Title Text Bold Font with element_text() To make both x and y-axis's title text in bold font, we will use axis. title argument to theme() function with element_text(face=”bold”). Note now both x and y axis's title text are in bold font.

How do you make text bold in LaTeX?

To make a text bold use \textbf command: Some of the \textbf{greatest} discoveries in science were made by accident.

How do you bold the Axis in Python?

The command fontweight='bold' can be used to make a textbox or label in figure bold.


1 Answers

Unfortunately you can't bold symbols using the bold font, see this question on tex.stackexchange.

As the answer suggests, you could use \boldsymbol to bold phi:

r'$\boldsymbol{\phi}$' 

You'll need to load amsmath into the TeX preamble:

matplotlib.rc('text', usetex=True) matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"] 
like image 83
Andy Hayden Avatar answered Sep 22 '22 07:09

Andy Hayden