我试图绘制3个树状图,两个在顶部,一个在底部。但我想出的唯一办法是:
fig, axes = plt.subplots(2, 2, figsize=(22, 14))
dn1 = hc.dendrogram(wardLink, ax=axes[0, 0])
dn2 = hc.dendrogram(singleLink, ax=axes[0, 1])
dn3 = hc.dendrogram(completeLink, ax=axes[1, 0])给我右下角的第四个空白图。有办法只绘制3幅图吗?
发布于 2020-11-21 13:48:01
您可以根据需要重新划分画布区域,并使用subplot的第三个参数来告诉它要绘制哪个单元格:
plt.subplot(2, 2, 1) # divide as 2x2, plot top left
plt.plt(...)
plt.subplot(2, 2, 2) # divide as 2x2, plot top right
plt.plt(...)
plt.subplot(2, 1, 2) # divide as 2x1, plot bottom
plt.plt(...)您还可以使用gridspec,如下所示:
gs = fig.add_gridspec(2, 2)
ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[1, :])
...https://stackoverflow.com/questions/64943656
复制相似问题