pythonmatplotlibsubplot

Python subplot 3 plots in 2x2 matrix (pyramid)


i want to plot a subplot as shown in version "a)". If i use plt.subplot2grid and colspan=2 i get version "b)" what i don't want. Here my current code:

ax1.subplot2grid((2,2), (0,0))
ax1.plot(m[:,0], m[:,8], color = "0")
ax2.subplot2grid((2,2), (0,1))
ax2.plot(m[:,0], m[:,9], color = "0")
ax3.subplot2grid((2,2), (1,0))
ax3.plot(m[:,0], m[:,10], color = "0", colespan=2)

Thanks in advance! enter image description here


Solution

  • You can change your grid to (2,4) and put colspan=2 on every axis:

    m = np.array([[0,1],[1,0]])
    
    fig = plt.figure()
    ax = plt.subplot2grid((2,4),(0,0), colspan=2)
    ax.imshow(m)
    ax1 = plt.subplot2grid((2,4),(0,2), colspan=2)
    ax1.imshow(m)
    ax2 = plt.subplot2grid((2,4),(1,1), colspan=2)
    ax2.imshow(m)
    

    Output:

    enter image description here