Eular
Eular

Reputation: 1807

Make everything bold

Well , I am making some plots and wants to make everything in bold font. I can can use weight="bold" to make bold font of label to ticks. Can also use the prop={'weight':'bold'} to make the legends lines bold, but I can't make the legend title bold. So, 1st question is there a way to make the legend title bold?

2nd,I tried to used matplotlib latex support to make the title bold, that did it but if I use rc('text', usetex=True) I cant use weight=bold and have to use \textbf{} everytime, also how do I make the ticks bold in this way.

3rd , If I use latex support then the font changes that I don't like. How do use the normal matplotlib font with using latex?

Upvotes: 12

Views: 34544

Answers (2)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339340

Making everything bold is rather easy. Just add

plt.rcParams["font.weight"] = "bold"
plt.rcParams["axes.labelweight"] = "bold"

at the top of the script.

enter image description here

import matplotlib.pyplot as plt
plt.rcParams["font.weight"] = "bold"
plt.rcParams["axes.labelweight"] = "bold"

plt.plot([2,3,1], label="foo")
plt.plot([3,1,3], label="bar")

plt.legend(title="Legend Title")
plt.xlabel("xLabel")

plt.show()

Upvotes: 28

Kelvin
Kelvin

Reputation: 66

You should be able to pass parameters into the plt.legend using the prop argument

legend_prop = {'weight':'bold'}
plt.plot(x, y, label='some label')
plt.legend(prop=legend_prop)

This would give you bold labels. Is this not what you're looking for?

Upvotes: 2

Related Questions