Reputation: 519
What is the best way to specify the font weight for a matplotlib legend? I can use:
matplotlib.rcParams.update({'legend.fontsize':12})
to set the font size but when I use
matplotlib.rcParams.update({'legend.fontweight':'bold'
}
It complains that "'legend.fontweight' is not a valid rc parameter"
Upvotes: 19
Views: 53473
Reputation: 53728
You can pass parameters into plt.legend
using the prop
argument. This dictionary allows you to select text properties for the legend.
import matplotlib
import matplotlib.pyplot as plt
legend_properties = {'weight':'bold'}
plt.plot([1,2,3], [4,5,6], label='Test')
plt.legend(prop=legend_properties)
plt.show()
Upvotes: 16