Reputation: 555
I am wondering how to set the font of xlabel
to be Arial using matplotlib
. I checked functions like Axes.set_xlabel
but does not see options to change that.
Upvotes: 0
Views: 8698
Reputation: 991
The Axes.set_xlabel
and pyplot's xlabel
functions can take the same keyword arguments as the Text
class. This is noted in the documentation in the Other Parameters section.
One of these arguments is family
, which can be used to set the font by family ('serif', 'sans-serif', etc., as shown in the font demo) or by font name. In your case it could be as simple as
plt.xlabel('My Label', family='Arial')
or
ax.set_xlabel('My Label', family='Arial')
# Assuming ax is an instance of Axes.
Upvotes: 2