Change the figure size in Matplotlib

Python

Matplotlib

Figure

Change size

Luc B.

Python

Matplotlib

It is often necessary to adjust the Matplotlib figure size to better suit a particular data set. For example, data collected over time benefits from a wide figure where signal details are clearer. Alternatively, bar charts are better off being taller so height differences are more obvious.

Code Example

Use the figsize argument to plt.figure() to change the figure size. figsize is a tuple with shape (width, height) where width and height are in inches.

import matplotlib.pyplot as plt

# Adjust the figure size here
plt.figure(figsize=(7, 2))

plt.title('Wide Figure')
plt.show()

png