Matplotlib - Title Font Size
Matplotlib - Title Font Size
To set a specific font size for the title of the plot in Matplotlib, you can use fontsize
parameter of the title() function.
plt.title('Sample Plot', fontsize=25)
You can replace 25
with other font size of your choice as per your requirement.
This customization allows you to tailor the appearance of your plot title to match the overall style of your visualizations.
1. "25" font size for Title in Maplotlib
In the following program, we shall 25 as font size for the title of plot.
Python Program
import matplotlib.pyplot as plt
# Example data
x = [1, 2, 3, 4, 5]
y = [20, 30, 55, 70, 60]
# Plot line
plt.plot(x, y, marker='o')
# Set title, with font size
plt.title('Sample Plot', fontsize=25)
# Show the plot
plt.show()
Output
2. "8" font size (smaller font) for Title in Maplotlib
In the following program, we shall 25 as font size for the title of plot.
Python Program
import matplotlib.pyplot as plt
# Example data
x = [1, 2, 3, 4, 5]
y = [20, 30, 55, 70, 60]
# Plot line
plt.plot(x, y, marker='o')
# Set title, with font size
plt.title('Sample Plot', fontsize=8)
# Show the plot
plt.show()
Output