Book Image

Mastering matplotlib

By : Duncan M. McGreggor, Duncan M McGreggor
Book Image

Mastering matplotlib

By: Duncan M. McGreggor, Duncan M McGreggor

Overview of this book

Table of Contents (16 chapters)
Mastering matplotlib
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Operating system shell executes the script.

  2. Python 3.4 is invoked, which then runs the script.

  3. matplotlib is imported.

  4. A main...