Skip to content
  • (+91) 9409548155
  • support@appdividend.com
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
Menu
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
  • Home
  • Pricing
  • Instructor
  • Tutorials
    • Laravel
    • Python
    • React
    • Javascript
    • Angular
  • Become A Tutor
  • About Us
  • Contact Us
Python

How to Change Font Size in Matplotlib in Python

  • 08 Dec, 2025
  • Com 0
How to Change Font Size in Matplotlib in Python

In Python, the best library for data visualization is Matplotlib. It provides various ways to deal with fontsize, color, family, and other creative controls.

Changing a font size is essential for improving readability in professional visualizations. Here are multiple ways to do that:

Method 1: Using rcParams (Global Configuration)

The most efficient way to change the font size in matplotlib is to set it globally for the entire script using rcParams.update() method.

The update() method provides more granular control over modifying multiple runtime configuration parameters, including the default font size for all text elements in a plot.

import matplotlib.pyplot as plt

plt.rcParams.update({
    "font.size": 14,              # Global default font size
    "axes.titlesize": 18,         # Title font
    "axes.labelsize": 14,         # x/y Label fonts
    "xtick.labelsize": 12,        # Tick labels
    "ytick.labelsize": 12,
})

plt.plot([1, 2, 3])
plt.title("Changed Font Sizes")
plt.xlabel("X")
plt.ylabel("Y")
plt.show()

Using rcParams (Global Configuration)

In this code, we set the global fontsize to 14 and then change the individual elements’ size, like axes.titlesize to 18, axes.labelsize to 14, xtick.labelsize to 12, ytick.labelsize to 12.

It ensures visual consistency across the following charts and is easy to manage going forward as well.

Method 2: Using a “fontsize” argument

If you are looking to change just the fontsize for individual text elements like Title, X/Y labels, Tick labels, or Legend for fine-tuned control, use the direct “fontsize” parameter.

import matplotlib.pyplot as plt

plt.plot([1, 2, 3])
plt.title("Changed Font Sizes", fontsize=20)
plt.xlabel("X", fontsize=14)
plt.ylabel("Y", fontsize=14)
plt.show()

Using a fontsize argument to change the size of the font in matplotlib

Method 3: Using FontProperties

The FontProperties allow us complete control over Font size, Weight, Family, and Stretch. For now, we just focus on Font size.

from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt

fp = FontProperties(size=18, weight='bold')

plt.plot([1, 2, 3])
plt.title("Changed Font Sizes", fontproperties=fp)
plt.xlabel("X")
plt.ylabel("Y")
plt.show()

Using FontProperties

It is helpful for branding or unique UI/UX designs. It has a unique and special use case.

Post Views: 14
Share on:
Krunal Lathiya

With a career spanning over eight years in the field of Computer Science, Krunal’s expertise is rooted in a solid foundation of hands-on experience, complemented by a continuous pursuit of knowledge.

How to Get the Last Day of the Month in Python
How to Convert Seconds to Hours Minutes Seconds in Python

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Address: TwinStar, South Block – 1202, 150 Ft Ring Road, Nr. Nana Mauva Circle, Rajkot(360005), Gujarat, India

Call: (+91) 9409548155

Email: support@appdividend.com

Online Platform

  • Pricing
  • Instructors
  • FAQ
  • Refund Policy
  • Support

Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of services

Tutorials

  • Angular
  • React
  • Python
  • Laravel
  • Javascript
Copyright @2024 AppDividend. All Rights Reserved
Appdividend