Spacing between some subplots but not all

后端 未结 2 1696
执笔经年
执笔经年 2020-12-14 03:13

I have a matplotlib plot in python with 3 subplots, all in 1 column.

I currently control the height of each subplot with:

gridspec.GridSpec(3, 1, hei         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 03:53

    In this particular case it's probably quickest to just add an invisible axes object between rows 2 and 3:

    import matplotlib.pyplot as plt
    
    gridspec = dict(hspace=0.0, height_ratios=[1, 1, 0.4, 3])
    fig, axs = plt.subplots(nrows=4, ncols=1, gridspec_kw=gridspec)
    axs[2].set_visible(False)
    

    I looked through the documentation and it appears that variable grid spacing is not supported. So we have to make do with workarounds like this one.

提交回复
热议问题