How to change figure size in Matplotlib

You can easily change figure size in Matplotlib with the following code. If you want to learn Python then I will highly recommend you to read This Book.

How to change figure size in Matplotlib
How to change figure size in Matplotlib

Figure Size or Plot Size in Matplotlib

The function plt.figure is used to change the figure size in matplotlib. You can change the value of width and height of the figure according to your requirement.

from matplotlib import pyplot as plt

x = [1,2,3,4,5]
y = [5,10,15,20,25]

plt.figure(figsize=(4, 2))

plt.title("Integers and Multiple")
plt.xlabel("Integers")
plt.ylabel("Multiple")

plt.plot(x,y)
plt.show()

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Top 10 Computer Vision Books with Python

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.