![]() |
VOOZH | about |
Matplotlib is a library for creating interactive Data visualizations in Python. The functions in Matplotlib make it work like MATLAB software. The legend method in Matplotlib describes the elements in the plot. In this article, we are going to Change Legend Font Size in Matplotlib.
Example 1: using fontsize
Here, we are trying to change the font size of the x and y labels.
Output:
Example 2: Changing text font size
This example changes the font size of items in the legend. The font size parameter can have integer or float values. It also accepts the string sizes like: ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large'.
Output:
Example 3: Using prop keyword
The prop keyword is used to change the font size property. It is used in Matplotlib as Using a prop keyword for changing the font size in legend.
Output:
The matplotlib.rcparams is a dictionary-like variable that has all the configuration settings to customize default parameters. The matplotlib.rc() command is used to change multiple settings with the use of keyword arguments.
Example:
Output: