(+84) 236.3827111 ex. 402

The two worlds of Matplotlib


There are two broad ways of using matplotlib's pyplot:

1. The first (and most common) way is not pythonic. It relies on global functions to build and display a global figure using matplotlib as a global state machine.

(This is easy for interactive use).

2. The second way is pythonic and object oriented and it is the best approach for programmatic use:

a. obtain an empty Figure from a global factory, then build the plot using the methods of the Figure and Axes classes; or

b. obtain a populated Axes (and its Figure container) using a plot method from the pandas data analysis library, which you can then pretty-up and save to file.