matplotlib subplot without gaps but the last one

后端 未结 2 1657
独厮守ぢ
独厮守ぢ 2021-01-27 07:51

I\'m try to figure out how can I achieve the result as reported in the title\'s topic, basically I wish obtain a subplot 1 column 4 row without gaps in the row 1,2,3 and a norma

2条回答
  •  我在风中等你
    2021-01-27 08:06

    An alternative to the answer by @GlobalTraveler is to chain two Gridspec definitions. See here for more information about the possibilities offered by GridSpec.

    outer_gs = matplotlib.gridspec.GridSpec(2,1, height_ratios=[3,1], hspace=0.2)
    inner_gs = matplotlib.gridspec.GridSpecFromSubplotSpec(3,1, subplot_spec=gs0[0], hspace=0)
    
    fig = plt.figure()
    ax1 = fig.add_subplot(inner_gs[0])
    ax2 = fig.add_subplot(inner_gs[1])
    ax3 = fig.add_subplot(inner_gs[2])
    ax4 = fig.add_subplot(outer_gs[1])
    

提交回复
热议问题