Need help in understanding "fig, ax = plt.subplots()"

In the guided explanation “fig, ax = plt.subplots()” is said to be the shortcut from the technique used previously.

I am quite literally stuck on this. Of which is this the shortcut . I have tried decomposing it into these two steps but getting error.

fig = plt.figure()
ax =fig.add_subplot()

Can you guide me what I need to do ?

Your question is not clear.
The shortcut plt.subplots() returns a fig object and an axes object. The Api provides the nrows and ncols arguments where you can pass in integers to specify the shape of a matrix of axes to be returned.

2 Likes

I found a resource online when I searched based on your explanation.

This really helped me in understanding the different ways to call the axes

1 Like