The execution flow
At the beginning of this chapter, we briefly sketched the flow of data from user creation to its display in a user interface. Having toured matplotlib's architecture, which included taking a side trip to the namespaces and dependency graphs, there is enough context to appreciate the flow of data through the code.
As we trace through our simple line example, remember that we used the pyplot
interface. There are several other ways by which one may use matplotlib. For each of these ways, the code execution flow will be slightly different.
An overview of the script
As a refresher, here's our code from simple-line.py
:
#! /usr/bin/env python3.4 import matplotlib.pyplot as plt def main () -> None: plt.plot([1,2,3,4]) plt.ylabel('some numbers') plt.savefig('simple-line.png') if __name__ == '__main__': main()
At the script level, here's what we've got:
Operating system shell executes the script.
Python 3.4 is invoked, which then runs the script.
matplotlib
is imported.A
main...