Greetings me fellow learners and my mentors, it is requested to tell me that why is their a comma between fig and ax?
Shouldn’t their be only one of them?
Also please explain in brief words what the subplot function is doing?
Hi @Talha1234, subplots
creates a figure (fig
) and a set of subplots (ax
), and that’s why it is returning two variables as Tom pointed out, and thus you use two variables to receive them.
In the code you provide, the arguments 1, 1
inside subplots
refers to arranging the subplots in 1 row and 1 column, which will give us a total of 1 subplot.
For another example, if we used plt.subplots(2, 2, ...)
instead, then the subplots will be arranged in 2 rows and 2 columns, giving us a total number of 4 plots, and in that case ax
will become an array.