How to change the font size of the title in a matplotlib figure ?

Published: February 06, 2019

DMCA.com Protection Status

To change the font size of the title in a matplotlib figure, use the parameter fontsize:

title('mytitle', fontsize=8)

How to change the font size of the title in a matplotlib figure ?
How to change the font size of the title in a matplotlib figure ?

#!/usr/bin/env python

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

x = np.arange(-4,8,0.1)
y = 6.0 / ( 1.0 + np.exp(-0.6*x) )

line, = plt.plot(x, y, '--', linewidth=2)

ax.grid(True)

plt.title('How to change the title font size in a matplotlib figure ?', fontsize=8)

plt.savefig('change_matplotlib_title_size.png')
plt.show()

References

Image

of