0

Aim - To make a 2×2 grid with lower row being occupied entirely by one axis.

Code till now: -

fig=plt.figure(figsize=[10,10])

ax0=fig.add_subplot(221)
ax0.scatter(xlist[:10],ylist[:10],color='red')

ax1=fig.add_subplot(222)
ax1.scatter(xlist[10:],ylist[10:],color='green')

ax3=fig.add_subplot(223)
ax3.scatter(xlist,ylist)


I want the ax3 to occupy the two lower spots in the 2nd row. I've a solution involving GridSpec, however I want to avoid GridSpec for now. This answer has answered it already. But I can't understand how plt.subplot(212) makes it work the way I want. How can he put a (212) in a (2×2) grid. I was told that (223) indicates 3rd position in a 2×2 grid. So how can (212) be valid there? Any help?

Note : - The Gridspec method uses ax2=fig.add_subplot(gs[:1]) to put ax2 at both [0,1] and [1,1] positions.

Pixel_Bear
  • 97
  • 1
  • 1
  • 11
  • Does this answer your question? [How to make an axes occupy multiple subplots with pyplot](https://stackoverflow.com/questions/2265319/how-to-make-an-axes-occupy-multiple-subplots-with-pyplot) – Jody Klymak Aug 03 '22 at 21:54
  • Suggest you in particular use the subplot_mosaic method. – Jody Klymak Aug 03 '22 at 21:55
  • I looked at that question's answers first. My issue is that I'm not getting the logic behind putting ```plt.subplot(212)``` makes it work. Thank you for the other method, I'll look into it. – Pixel_Bear Aug 04 '22 at 19:48
  • subplot(2,1,2) means 2 rows, 1 column, put the subplot in the second slot (i.e fill the bottom row) https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplot.html – Jody Klymak Aug 06 '22 at 03:41

0 Answers0