matplotlib subplot without gaps but the last one

后端 未结 2 1631
独厮守ぢ
独厮守ぢ 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:10

    One you could solve this is by inserting another subplot and them playing around with the height ratios. Let's start with the results;

    Which is achieved by:

    import matplotlib.pyplot as plt
    
    
    gs = dict(\
             height_ratios = [1, 1, 1, .2, 1]
             )
    
    fig, ax = plt.subplots(5, 1, gridspec_kw = gs)
    fig.subplots_adjust(hspace = 0)
    ax[3].axis('off')
    fig.show()
    

    You need to play around with the ratios to achieve the desired results, but the approach could be used to achieve what you want.

提交回复
热议问题