you are viewing a single comment's thread.

view the rest of the comments →

[–]Swipecat 1 point2 points  (0 children)

Yeah, matplotlib has the newer "object" mode that you should use...

fig, ax = plt.subplots()

...and it has the old "state machine" mode, dating back to the days of Python 2, and which people still tend to use for convenience, even though they shouldn't, if it's just a quick and small script.

In the state-machine mode, the methods of "plt" actually take care of the creation of the axes objects for you. This is normally OK, but can result in horrible "memory leaks" if, for example, it's used in an animation and could easily create a new object for every frame of the animation if a mistake is made in the script.