【问题标题】:How to plot multiples of a fixed subplot2grid arrangement each consisting of several plots into one figure?如何将多个固定的 subplot2grid 排列绘制成一个图形,每个排列由多个图组成?
【发布时间】:2023-03-12 05:23:01
【问题描述】:

将以下内容想象为形状为 (n,1) 的图形中的一个子图:

ax0 = plt.subplot2grid((6,1), (0,0), rowspan=1)
ax1 = plt.subplot2grid((6,1), (1,0), sharex=ax1, rowspan=4)
ax2 = plt.subplot2grid((6,1), (5,0), sharex=ax1, rowspan=1)

(subplot2grid 的排列可能比这更复杂。)

我想在一个图中绘制 n 个这些。

我怎样才能做到这一点?

【问题讨论】:

标签: python matplotlib subplot


【解决方案1】:

这似乎有效:

fig = plt.figure(constrained_layout=True)

gs0 = fig.add_gridspec(len(df_list), 1)

for i,v in enumerate(df_list):
    gs00 = gs0[i].subgridspec(6, 1)
    ax0 = fig.add_subplot(gs00[0, 0])    
    ax1 = fig.add_subplot(gs00[1:5, 0])
    ax2 = fig.add_subplot(gs00[5, 0])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 2021-02-13
    • 2020-10-06
    • 1970-01-01
    • 2023-01-20
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多