How to set the matplotlib figure default size in ipython notebook?

MatplotlibServer Side ProgrammingProgramming

To set the matplotlib figure default size in iPython, use the following steps −

  • To check the default figure size, use plt.rcParams["figure.figsize"] over the ipython shell.

  • Now to set the figure size, override the plt.rcParams["figure.figsize"] variable with a tuple i.e., (20, 10).

  • After overriding the plt.rcParams["figure.figsize"] variable, you can use it to get changed figure size.

Example

import matplotlib.pyplot as plt

print("Before, figure default size is: ", plt.rcParams["figure.figsize"])
plt.rcParams["figure.figsize"] = (20, 10)
print("After, figure default size is: ", plt.rcParams["figure.figsize"])

Output

Before, figure default size is: [6.4, 4.8]
After, figure default size is: [20.0, 10.0]
raja
Published on 15-Mar-2021 07:44:10
Advertisements