plt.figuresize
时间: 2023-07-09 07:06:46 浏览: 60
正确的方法是 plt.figure(figsize=(width, height)),其中 width 和 height 是以英寸为单位的宽度和高度。它用于设置一个新的图形并指定其大小。例如,要创建一个宽度为 8 英寸,高度为 6 英寸的图形,可以使用以下代码:
```
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 6))
```
这将创建一个新的宽度为 8 英寸,高度为 6 英寸的图形,并使其成为当前图形。接下来,您可以使用其他 Matplotlib 函数来添加数据、绘制图形等。
相关问题
plt.figure()
Sorry, as an AI language model, I cannot perform graphical operations. However, I can provide you with some information regarding the "plt.figure()" function.
"plt.figure()" is a function in the matplotlib library of Python that creates a new figure for plotting. It can take several optional arguments like "figsize", "dpi", "facecolor", "edgecolor", etc., to customize the size, resolution, and background color of the figure. Once a figure is created, it can be used to plot data using other functions like "plt.plot()", "plt.scatter()", etc.
plt.figure()更改大小
如果你想在 matplotlib 中更改 figure 的大小,你可以使用 `plt.figure(figsize=(width, height))`,其中 `width` 和 `height` 表示你想要的 figure 的宽度和高度,单位是英寸。例如,如果你想要一个宽度为 8 英寸,高度为 6 英寸的 figure,可以这样写:
```python
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8, 6))
```
你也可以在创建 figure 后使用 `fig.set_size_inches(width, height)` 更改其大小,例如:
```python
fig = plt.figure()
fig.set_size_inches(8, 6)
```
这将把 figure 的大小更改为宽度为 8 英寸,高度为 6 英寸。