Plt.subplot()

hi guys

I’m new here and sorry for my dumb question… but i really got confused about the numbering of subplot.

So here is the question from https://www.codecademy.com/paths/visualize-data-with-python/tracks/graphing-in-python-dvp/modules/matplotlib-dvp/lessons/matplotlib-i/exercises/subplots-ii :

We are asked to create a figure that has two rows of subplots. It should have:

Question 2
use the plt.subplot() command to select the box in the first column of the second row (the one with a square in it). Plot parabola vs x in this box.
Hint:
The bottom left subplot is the third subplot from a grid with 2 rows and 2 columns, so the command would be:

plt.subplot(2, 2, 3)

My confusion is, where does the ‘third’ comes from? I thought in a way that when counting the number, from top to bottom and from left to right, the subplot with the square in it should the the second one and hence the code should be:

plt.subplot(2, 2, 2)

Could anyone help me out? Thanks in advance:)

Welcome to the forums!
It’s not a dumb question at all. It can be a little confusing! :slight_smile:

plt.subplot takes three arguments: nrows, ncols, index.
Here, the index starts at 1 going left to right from the upper left.

https://nickmccullum.com/python-visualization/subplots/

And, official documentation:

1 Like

cheers lisa, i think i get it!

1 Like