Matplotlib Figure Size: Quick Guide

In matplotlib, the figure() function can be used to set the size of the image, the specific method is as follows:

import matplotlib.pyplot as plt

# 创建一个新的figure对象,并设置图片大小为宽10英寸,高6英寸
plt.figure(figsize=(10, 6))

# 绘制图形
plt.plot([1, 2, 3, 4])

# 显示图形
plt.show()

In the code above, the figsize parameter takes a tuple with two values representing the width and height of the image in inches. This allows you to set the size of the image.

bannerAds