I'm learning to use matplotlib
by studying examples, and a lot of examples seem to include a line like the following before creating a single plot...
fig, ax = plt.subplots()
Here are some examples...
I see this function used a lot, even though the example is only attempting to create a single chart. Is there some other advantage? The official demo for subplots()
also uses f, ax = subplots
when creating a single chart, and it only ever references ax after that. This is the code they use.
# Just a figure and one subplot
f, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')