子图中的wspace和hspace,轴宽-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
weichaochenweichao 回答:子图中的wspace和hspace,轴宽-python3

由于子图返回一个Axes对象,而subplots_adjust是一个Figure方法,因此会出现错误。如果要同时返回图形对象和轴对象,则需要调用子图。否则,您可以简单地调用plt.subplots_adjust()。

本文链接:https://www.f2er.com/3047011.html

大家都在问