Setting the Matplotlib title in bold while using "Times New Roman

To set the Matplotlib title in bold while using "Times New Roman", we can use fontweight="bold" along with fontname="Times New Roman" in the set_title() method.

Basic Example

Here's how to create a scatter plot with a bold Times New Roman title ?

import numpy as np
import matplotlib.pyplot as plt

# Set figure size
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

# Create figure and subplot
fig, ax = plt.subplots()

# Generate random data points
x = np.random.rand(100)
y = np.random.rand(100)

# Create scatter plot
ax.scatter(x, y, c=y, marker="v")

# Set title with Times New Roman font and bold weight
ax.set_title('Scatter Plot With Random Points', 
             fontname="Times New Roman", 
             size=28, 
             fontweight="bold")

plt.show()

Alternative Method Using fontdict

You can also specify font properties using a dictionary ?

import numpy as np
import matplotlib.pyplot as plt

# Create sample data
x = np.linspace(0, 10, 50)
y = np.sin(x)

# Plot the data
plt.plot(x, y, 'b-', linewidth=2)

# Define font properties
font_properties = {
    'fontname': 'Times New Roman',
    'fontweight': 'bold',
    'fontsize': 16
}

# Set title using fontdict
plt.title('Sine Wave Plot', fontdict=font_properties)

plt.xlabel('X values')
plt.ylabel('Y values')
plt.grid(True, alpha=0.3)
plt.show()

Font Properties Reference

Parameter Description Example Values
fontname Font family name 'Times New Roman', 'Arial', 'Helvetica'
fontweight Font weight 'bold', 'normal', 'light', 'heavy'
fontsize Font size 12, 16, 'large', 'x-large'

Multiple Subplots with Consistent Styling

When working with multiple subplots, you can apply consistent title formatting ?

import numpy as np
import matplotlib.pyplot as plt

# Create sample data
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)

# Create subplots
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

# Plot data on both subplots
ax1.plot(x, y1, 'r-')
ax2.plot(x, y2, 'b-')

# Set titles with consistent formatting
title_style = {'fontname': 'Times New Roman', 'fontweight': 'bold', 'fontsize': 14}

ax1.set_title('Sine Wave', **title_style)
ax2.set_title('Cosine Wave', **title_style)

plt.tight_layout()
plt.show()

Conclusion

Use fontname="Times New Roman" and fontweight="bold" parameters in set_title() to create bold titles. For consistent styling across multiple plots, define font properties in a dictionary and reuse them.

Updated on: 2026-03-25T22:10:38+05:30

10K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements