【发布时间】:2021-03-23 19:07:24
【问题描述】:
我一直觉得 matplotlib 子图令人困惑,所以我想知道是否有人可以展示如何生成以下子图排列: Subplot Image
提前致谢。
【问题讨论】:
标签: python matplotlib plot subplot
我一直觉得 matplotlib 子图令人困惑,所以我想知道是否有人可以展示如何生成以下子图排列: Subplot Image
提前致谢。
【问题讨论】:
标签: python matplotlib plot subplot
您可以使用plt.GridSpec 轻松创建不同大小的子图。
cols = 5 #number of columns in the grid
s = 2 #width of top right subplot in #cells
w = 1 #spacing between subplot columns
fig = plt.figure()
gs = plt.GridSpec(2, cols, figure=fig, wspace=w)
ax1 = fig.add_subplot(gs[0, :-s])
ax2 = fig.add_subplot(gs[0, -s:])
ax3 = fig.add_subplot(gs[1, :-s])
【讨论】:
gs = fig.add_gridspec(2, cols)