我如何确定一个子图(
例如,在这个图中,只有两个子图被填充,其余的子图是空的。
注意:必须将
基本上我想要一个稀疏的图形。一些行中的子图可能是空的,但它们应该被停用(没有轴必须可见)。完全空的行必须被删除,不能设置为不可见。
AxesSubplot
)是否为空?我想要禁用空的子图轴并删除完全空的行。例如,在这个图中,只有两个子图被填充,其余的子图是空的。
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
。基本上我想要一个稀疏的图形。一些行中的子图可能是空的,但它们应该被停用(没有轴必须可见)。完全空的行必须被删除,不能设置为不可见。