# Python Matplotlib Change Text Font Style: A Beginner Guide – Matplotlib Tutorial

By | November 29, 2019

To change the font style of text is very easy in python matplotlib. In this tutorial, we will tell you how to do. However, as a python beginner, you should know two basic concepts: font family and font, which will be used in this tutorial.

## Preliminaries

To change the font style of text in matplotlib, you should know what font style you will use in your python application, which means what font family and font you plan to apply.

To know more about font family and font, you can read this tutorial.

Understand Font Families and Fonts: A Beginner Guide – Python Tutorial

In this tutorial, we will apply font family: sans-serif and its font: Arial for text in python matplotlib application.

## How to change the font style of text in matplotlib?

First, we set font family for text.

#-*- coding: UTF-8 -*-
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'

Then we continue to set font for font family: sans-serif

rcParams['font.sans-serif'] = ['Arial']

Then we will create a plot using matplot.

Here we will create a scatter plot with labels to show the effect of our font style set above.

To know how to create a plot with labels, you can refer to this tutorial.

Python Matplotlib Implement a Scatter Plot with Labels: A Completed Guide – Matplotlib Tutorial

The effect is:

From the result, we can find that the font style of all text in plot is changed.