How to make an axes occupy multiple subplots with pyplot (Python)

前端 未结 5 1925
盖世英雄少女心
盖世英雄少女心 2021-01-31 14:32

I would like to have three plots in single figure. The figure should have a subplot layout of two by two, where the first plot should occupy the first two subplot cells (i.e. th

5条回答
  •  情话喂你
    2021-01-31 15:20

    The Using Gridspec to make multi-column/row subplot layouts shows a way to do this with GridSpec. A simplified version of the example with 3 subplots would look like

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    
    gs = fig.add_gridspec(2,2)
    ax1 = fig.add_subplot(gs[0, 0])
    ax2 = fig.add_subplot(gs[0, 1])
    ax3 = fig.add_subplot(gs[1, :])
    
    plt.show()
    

提交回复
热议问题