Figure creation (two methods available ?)

In the multiple plots missions we learned that the creation of a figure and the axes is done this way :
fig = plt.figure()

But when passing to the bar plots mission the figure and axes were created like this :
fig, ax = plt.subplots()

Does the two codes do the same things ? For me the axe is defined as an attribute of the figure in the first method, but in the second method the axe and method are created as the same objects.

Can somebody clarify this point please ?

plt.figure creates a new figure. But the figure has no axes in it, you’ll have to add axeses using fig.add_subplot()

plt.subplots creates a new figure with a set of subplots. It is best for creating multiple subplots.

You can use any depending on what you want to achieve as fast as you want.

1 Like

Thanks @info.victoromondi :+1: