子图中的 wspace 和 hspace,轴的宽度 - python3

wspace and hspace in subplots, width of axes - python3

如何在子图中制作 wspace 和 hspace? 我有一个代码类型:

plt.figure(figsize=(12, 10))

fig1=plt.subplot(231)
plt.plot(x, y)

fig2=plt.subplot(232)
plt.plot(x, y)

fig3=plt.subplot(233)
plt.plot(x, y)

fig4=plt.subplot(234)
plt.plot(x, y)

fig5=plt.subplot(235)
plt.plot(x, y)

fig6=plt.subplot(236)
plt.plot(x, y)

我尝试为单个图形增大 wspace:

plt.figure(figsize=(12, 10))

fig1=plt.subplot(231)
fig1.subplots_adjust(wspace=2)

错误:

    fig1.subplots_adjust(wspace=2)
AttributeError: 'AxesSubplot' object has no attribute 'subplots_adjust'

以及如何改变所有轴的宽度?

我试过:

import matplotlib as mpl

mpl.rcParams['lines.linewidth'] = 2

你得到一个错误,因为 subplot returns 一个 Axes 对象和 subplots_adjust 是一个 Figure 方法。如果要同时返回 Figure 和 Axes 对象,则需要调用 subplots。否则,您可以简单地调用 plt.subplots_adjust()。