Matplotlib default figure size

In this Python tutorial, we will discuss Matplotlib default figure size in python. Here we will cover different examples related to change default figure size using matplotlib. And we will also cover the following topics:

  • matplotlib default figure size
  • jupyter notebook matplotlib default figure size
  • google colab matplotlib default figure size
  • visual studio matplotlib default figure size
  • spyder matplotlib default figure size
  • jupyter lab matplotlib default figure size

matplotlib default figure size

To check the default figure size in matplotlib you have to print the default settings of matplotlib.

The syntax to print default settings is as given below:

# Default all settings

matplotlib.pyplot.rcParams

You can also check only the default figure size in matplotlib.

The syntax to check default figure size:

# Default figure size

matplotlib.pyplot.rcParams["figure.figsize"]

                        OR

matplotlib.pyplot.rcParams.get('figure.figsize)

Now, let’s see an example of checking default settings in matplotlib

# Import Library

import matplotlib.pyplot as plt

# Check default settings

print(plt.rcParams)
matplotlib default figure size
” Default settings “

Read Matplotlib savefig blank image

jupyter notebook matplotlib default figure size

In this section, we are going to check the default size of the figure in “jupyter notebook” and try to change it according to need.

The syntax to get default figure size in jupyter notebook is as below:

matplotlib.pyplot.rcParams.get('figure.figsize') 

Example of jupyter notebook:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" The Default figure size in jupyter notebook is: ", fig_size)
jupyter notebook matplotlib default figure size
” Output of jupyter notebook “

Matplotlib provides the functionality to change the default size of the figure in the jupyter notebook.

Example:

# Import Library

import matplotlib.pyplot as plt

# New figure size

new_size = plt.rcParams["figure.figsize"] = (50,50)

# Print

print(" New figure size: ",new_size)
matplotlib default figure size jupyter notebook
” New Figure size set in jupyter notebook “

After changing the default figure size now check what happens to default figure size settings:

Code:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" After, New Default figure size in jupyter notebook is: ", fig_size)
matplotlib juypter notebook default figure size
” Output after changing Default Figure Size “

Read Python Turtle Circle

Google colab matplotlib default figure size

In this section, we are going to check the default size of the figure in “google colab” and try to change it according to need.

The syntax to get the default figure size in google colab is as below:

matplotlib.pyplot.rcParams.get('figure.figsize') 

Example of google colab:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" The Default figure size in google colab is: ", fig_size)
google colab matplotlib default figure size
” Output of google colab “

Matplotlib provides the feature to change the default size of the figure in google colab.

Example:

# Import Library

import matplotlib.pyplot as plt

# New figure size

new_size = plt.rcParams["figure.figsize"] = (20,15)

# Print

print(" New figure size: ",new_size)
matplotlib default figure size google colab
” New Figure size set in google colab “

Now let’s see after changing the default figure size what happens to default figure size settings:

Code:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" After, New Default figure size in google colab is: ", fig_size)
matplotlib googe colab default figure size
” Output after changing Default Figure Size “

Read Matplotlib save as png

Visual studio matplotlib default figure size

In this section, we are going to check the default size of the figure in “visual studio” and try to change it according to need.

The syntax to get the default figure size in visual studio is as below:

matplotlib.pyplot.rcParams.get('figure.figsize') 

Example of the visual studio:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

print(plt.rcParams.get('figure.figsize')) 
matplotlib default figure size visual studio
” Output of visual studio “

Matplotlib provides the feature to change the default size of the figure in the visual studio.

Example:

# Import Library

import matplotlib.pyplot as plt

# New figure size

new_size = plt.rcParams["figure.figsize"] = (35, 10)

# Print

print("After changing figure default size is: ",new_size)
visual studio matplotlib default figure size
Output after changing figure size “

Read Matplotlib bar chart labels

spyder matplotlib default figure size

In this section, we are going to check the default size of the figure in “spyder” and try to change it according to need.

The syntax to get the default figure size in spyder is as below:

matplotlib.pyplot.rcParams.get('figure.figsize') 

Example of spyder notebook:


# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" The Default figure size in jupyter notebook is: ", fig_size)
spyder matplotlib default figure size
” Output of spyder “

Matplotlib provides the functionality to change the default size of the figure in the spyder.

Example:


# Import Library

import matplotlib.pyplot as plt

# New figure size

new_size = plt.rcParams["figure.figsize"] = (15,20)

# Print

print(" New figure size: ",new_size) 
matplotlib default figure size spyder
” New Figure size set in spyder “

Also, Read Add text to plot matplotlib in Python

jupyter lab matplotlib default figure size

Here, we are going to check the default size of the figure in “jupyter lab” and try to change it according to need.

The syntax to get the default figure size in jupyter lab is as below:

matplotlib.pyplot.rcParams.get('figure.figsize') 

Example of jupyter lab:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" The Default figure size in jupyter lab is: ", fig_size)
matplotlib default figure size jupyter lab
” Output of jupyter lab “

Matplotlib provides the feature to change the default size of the figure in the jupyter lab.

Example:

# Import Library

import matplotlib.pyplot as plt

# New figure size

new_size = plt.rcParams["figure.figsize"] = (45, 52)

# Print

print(" New figure size: ",new_size)
 
jupyter lab matplotlib default figure size
” New Figure size set in jupyter lab “

Now let’s see after changing the default figure size what happens to default figure size settings:

Code:

# Import Library

import matplotlib.pyplot as plt

# Default figure size

fig_size = plt.rcParams.get('figure.figsize')

# Print

print(" After, New Default figure size in jupyter lab is: ", fig_size) 
matplotlib jupyter lab default figure size
” Output after changing Default Figure Size “

You may like the following Matplotlib tutorials:

In this Python tutorial, we have discussed the “Matplotlib default figure size” and we have also covered some examples related to it. These are the following topics that we have discussed in this tutorial.

  • matplotlib default figure size
  • jupyter notebook matplotlib default figure size
  • google colab matplotlib default figure size
  • visual studio matplotlib default figure size
  • spyder matplotlib default figure size
  • jupyter lab matplotlib default figure size