When I first started using Matplotlib in Python, I often created heatmaps and contour plots that looked great, until I noticed the colorbar title was too small to read.
If you’ve ever created a plot where the colorbar label looks tiny compared to the rest of your chart, you’re not alone. It’s one of those small details that can make your visualization look either polished or sloppy.
In this tutorial, I’ll show you how to change the colorbar title font size in Matplotlib using different methods. I’ll also share a few practical tips that I’ve learned from more than a decade of working with Python and data visualization.
What is a Colorbar in Matplotlib?
A colorbar in Matplotlib is a visual guide that shows the mapping between data values and colors.
When you create a heatmap, contour plot, or any chart that uses a colormap, a colorbar helps viewers interpret the meaning of the colors.
For example, in a temperature map of the United States, blue might represent colder areas, and red might represent warmer areas. The colorbar shows this scale clearly.
Adjust the Colorbar Title Font Size
By default, Matplotlib assigns a small font size to colorbar titles and labels.
This default setting might look fine on small plots, but when you’re preparing a presentation, report, or dashboard, you’ll want to adjust the font size to make the chart readable from a distance.
Changing the colorbar title font size in Python is simple once you know which parameters to use.
Method 1 – Change Colorbar Title Font Size Using set_label()
The easiest way to change the colorbar title font size is by using the set_label() method with the fontsize parameter.
This method works directly on the colorbar object and doesn’t require any additional imports or style modifications.
Here’s how I usually do it:
import matplotlib.pyplot as plt
import numpy as np
# Sample data: temperature values across the USA
np.random.seed(42)
data = np.random.rand(10, 10) * 100 # Random temperature data
# Create the heatmap
plt.figure(figsize=(8, 6))
heatmap = plt.imshow(data, cmap='coolwarm')
# Add colorbar
cbar = plt.colorbar(heatmap)
# Set colorbar title and change font size
cbar.set_label('Temperature (°F)', fontsize=14)
# Add plot title and labels
plt.title('Average Temperature Distribution Across the USA', fontsize=16)
plt.xlabel('Longitude Index')
plt.ylabel('Latitude Index')
plt.show()You can see the output in the screenshot below.

This simple method is perfect for most cases. By specifying fontsize=14, the colorbar title becomes larger and more readable, matching the overall style of the plot.
Method 2 – Use set_title() for More Control
Sometimes, you may want to position the title differently or apply other font properties like bold or italic. In such cases, you can use the set_title() method on the colorbar’s ax (axis) object.
Here’s an example:
import matplotlib.pyplot as plt
import numpy as np
# Simulated rainfall data across different US regions
rainfall = np.random.rand(12, 12) * 20 # Inches of rainfall
plt.figure(figsize=(8, 6))
plot = plt.imshow(rainfall, cmap='Blues')
# Create colorbar
cbar = plt.colorbar(plot)
# Set colorbar title using the axis object
cbar.ax.set_title('Rainfall (inches)', fontsize=16, fontweight='bold', pad=15)
plt.title('Monthly Rainfall Distribution in the USA', fontsize=18)
plt.xlabel('Longitude Index')
plt.ylabel('Latitude Index')
plt.show()You can see the output in the screenshot below.

The pad parameter adds spacing between the colorbar and the title. This method gives you more flexibility to style the title, for example, making it bold or adjusting its position.
Method 3 – Customize Font Using matplotlib.font_manager
If you want to use a custom font (like Arial, Times New Roman, or a corporate font), you can use the FontProperties class from matplotlib.font_manager.
This approach is useful when you’re preparing professional reports or publications.
Here’s how I do it:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import font_manager
# Generate population density data
density = np.random.rand(15, 15) * 500
plt.figure(figsize=(8, 6))
plot = plt.imshow(density, cmap='viridis')
# Define custom font properties
font_prop = font_manager.FontProperties(family='Arial', size=14, weight='bold')
# Add colorbar
cbar = plt.colorbar(plot)
# Apply custom font to colorbar title
cbar.set_label('Population Density (per sq. mile)', fontproperties=font_prop)
plt.title('Population Density Map of the USA', fontsize=18)
plt.xlabel('Longitude Index')
plt.ylabel('Latitude Index')
plt.show()You can see the output in the screenshot below.

This method allows you to fully control the font style, making your charts consistent with your organization’s design guidelines.
Method 4 – Change Font Size Globally Using rcParams
If you’re working on multiple plots and want to maintain a consistent look, it’s better to define a global font size using Matplotlib’s rcParams.
This saves time because you don’t have to specify the font size in every plot.
Here’s how to do it:
import matplotlib.pyplot as plt
import numpy as np
# Set global font size for colorbar titles
plt.rcParams['axes.titlesize'] = 16
plt.rcParams['axes.labelsize'] = 14
plt.rcParams['font.size'] = 12
# Create data for heatmap
data = np.random.rand(20, 20)
plt.figure(figsize=(9, 7))
plot = plt.imshow(data, cmap='plasma')
# Add colorbar
cbar = plt.colorbar(plot)
cbar.set_label('Data Intensity', fontsize=plt.rcParams['axes.labelsize'])
plt.title('Data Intensity Visualization (Python Example)')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.show()You can see the output in the screenshot below.

Using rcParams ensures consistency across all your Matplotlib visualizations. This is especially useful when you’re creating dashboards or scientific reports that require uniform formatting.
Method 5 – Adjust Font Size Dynamically Based on Figure Size
If you’re working with dynamic or resizable figures, you can adjust the colorbar title font size automatically based on the figure dimensions.
This approach uses a simple formula to scale the font size relative to the figure width.
import matplotlib.pyplot as plt
import numpy as np
# Generate random elevation data
elevation = np.random.rand(30, 30) * 2000
fig, ax = plt.subplots(figsize=(10, 8))
plot = ax.imshow(elevation, cmap='terrain')
# Add colorbar
cbar = plt.colorbar(plot)
# Dynamically adjust font size based on figure width
font_size = fig.get_size_inches()[0] * 1.5
cbar.set_label('Elevation (ft)', fontsize=font_size)
plt.title('Elevation Map of the United States', fontsize=font_size + 2)
plt.xlabel('Longitude Index')
plt.ylabel('Latitude Index')
plt.show()This method ensures your colorbar title always looks proportionate, no matter how large or small the figure is. It’s a great trick when you’re exporting plots for different screen sizes or print layouts.
Additional Tips for Better Colorbar Presentation in Python
Here are a few extra tips that I’ve learned over the years while working with Matplotlib in Python:
- Use contrasting colors: Make sure your colorbar text color stands out against the background.
- Keep labels short: Long titles can overlap with the colorbar. Use concise labels like “Temp (°F)” instead of full sentences.
- Align with plot theme: Match the font style and size of your colorbar title with the main plot title for a cohesive look.
- Use tight_layout() or constrained_layout=True: This ensures your colorbar and labels don’t get cut off when saving the figure.
Example:
plt.tight_layout()This small step can save you a lot of frustration when exporting figures.
Adjusting the colorbar title font size in Matplotlib might seem like a small detail, but it significantly improves the readability and professionalism of your Python visualizations.
Whether you’re working on a quick data analysis project or preparing a presentation for your team, these methods give you full control over how your colorbar titles appear.
Personally, I prefer the set_label() method for quick edits and the FontProperties method when I need custom fonts for reports.
You may also like to read:
- How to Save a Matplotlib Axis as PNG in Python
- How to Save Matplotlib Chart as PNG
- Change the Pie Chart Title Font Size in Matplotlib
- Change Bar Chart Title Font Size in Matplotlib

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.