

With this, we come to the end of this tutorial. You can make similar changes to other text components of the plot as well and this way you do not alter the default configurations.įor more on customizing matplotlib default parameters, refer to this guide.

Note that except for the axes title (which has font “Comic Sans MS”) all other text components have the default font style. Note that first, we used the rcdefaults() function to reset the matplotlib configurations to their defaults, and then went ahead to update our font. # reset the plot configurations to defaultĪx.set_title("Employee Growth at A", fontname="Comic Sans MS") For example, let’s change the font of our axes title in the line chart. Change font of individual text component of a plotĪlternatively, you can also change the font of individual text components such as axes title, axes labels, tick labels, etc of an axes object without changing the global settings. You can see that the above scatter plot also has the text with the new default font family. Let’s create a different plot to see this in action.
:max_bytes(150000):strip_icc()/008_how-to-change-skype-username-4173039-b2b3da20a6ec4b8eb557e5334f4d2f4f.jpg)
Since we have updated the default font style, all the following plots will have the same font family(“fantasy” in our case). You can see in the above plot that the font of all the text elements is now from a different font family (“fantasy”). The following is the syntax: # set the font globally You can also set the font individually for text components of a matplotlib axes object such as axes labels, title, tick labels, etc. You can change the font globally for all the plots using rcParams. In this tutorial, we’ll look at how to change the font types of texts in matplotlib plots.
