If you need a link axfor later reference:
ax = fig.add_subplot(111)
gives you one:
plt.subplot(111)
you need to do something like:
ax = plt.gca()
Similarly, if you want to manipulate the figure later:
fig = plt.figure()
gives you a link right away, not:
fig = plt.gcf()
Obtaining explicit links is even more useful if you are working with multiple digit subtasks. For comparison:
figures = [plt.figure() for _ in range(5)]
from:
figures = []
for _ in range(5):
plt.figure()
figures.append(plt.gcf())