I have a problem with Matplotlib’s subplots. I do not know the number of subplots I want to plot beforehand, but I know that I want them in two rows. so I cannot use
plt.subplot(212)
because I don’t know the number that I should provide.
It should look like this:

Right now, I plot all the plots into a folder and put them together with illustrator, but there has to be a better way with Matplotlib. I can provide my code if I was unclear somewhere.
My understanding is that you only know the number of plots at runtime and hence are struggling with the shorthand syntax, e.g.:
Thankfully, to save you having to do some awkward math to figure out this number programatically, there is another interface which allows you to use the form:
So in your case, given you want
nplots, you can do:Alternatively, there is also a slightly more pythonic interface which you may wish to be aware of:
(Notice that this was
subplots()not the plainsubplot()). Although I must admit, I have never used this latter interface.HTH