如何确定子图(AxesSubplot
)是否为空?我想停用空子图的空轴并删除完全空行。删除matplotlib中的空子图图
例如,在此图中只填充了两个子图,其余子图都是空的。
import matplotlib.pyplot as plt
# create figure wit 3 rows and 7 cols; don't squeeze is it one list
fig, axes = plt.subplots(3, 7, squeeze=False)
x = [1,2]
y = [3,4]
# plot stuff only in two SubAxes; other axes are empty
axes[0][1].plot(x, y)
axes[1][2].plot(x, y)
# save figure
plt.savefig('image.png')
注:必须设置squeeze
到False
。
基本上我想要一个稀疏的数字。一些行中的子图可以是空的,但是它们应该被禁用(不必显示轴)。完全空行必须删除,不能设置为不可见。
你可以使用subplot2grid? – DavidG
我认为这将是可能的,但它如何解决我的问题确定空子图? – hotsplots
查看我的回答,看看它是否适用于您的问题 – DavidG