1

I read through Difference between plt.subplots() and plt.figure(), and I'm curious if there's any different in the functionality between

1)

fig, ax = plt.subplots()

and

2.

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

I think the answer is no; however, I came across a code-segment that used both styles, so I'm lead to believe that there's a difference. Thanks.

DavidG
  • 24,279
  • 14
  • 89
  • 82
Joey
  • 209
  • 2
  • 7

1 Answers1

0

There is not much of difference. However, I personally encourage the use of plt.subplots. Because you can store each subplot in ax and use it as an iterable. When you are dealing with similar subplots, this is very sharp and convenient. Also, you can arrange the disposal better with plt.subplots and even delete and merge subplots.
https://matplotlib.org/stable/gallery/subplots_axes_and_figures/gridspec_and_subplots.html
Delete a subplot