Get startedGet started for free

Save a figure with different sizes

Before saving your visualization, you might want to also set the size that the figure will have on the page. To do so, you can use the Figure object's set_size_inches method. This method takes a sequence of two values. The first sets the width and the second sets the height of the figure.

Here, you will again have a Figure object called fig already provided (you can run plt.show if you want to see its contents). Use the Figure methods set_size_inches and savefig to change its size and save two different versions of this figure.

This exercise is part of the course

Introduction to Data Visualization with Matplotlib

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Set figure dimensions and save as a PNG
____
____
Edit and Run Code