Chapter 2. The matplotlib Architecture

As software systems age, they tend to undergo a natural evolution through processes such as feature addition and debugging. The resultant codebase embodies the familiar tension between maintaining the old code and at the same time offering the end users an improved product. Architectures for long-term projects are not something that were originally carved in stone and adhered to monomaniacally ever since. Rather, they are living, adaptive concepts that guide the plans and activities of a project's contributors.

The matplotlib module arose out of such an environment, and it has continuous goals of refining and improving its architecture and updating its older bits to follow the best practices of and the latest advances in not only the project itself, but also the wider Python community over the years since its inception.

In this chapter, we will perform the following tasks:

  • Review the original design goals of matplotlib and explore its evolution
  • Examine the current architecture at a high level using the metaphors put forth by the core developers of matplotlib
  • Dive into the details of the three major layers of the matplotlib architecture
  • Explore the matplotlib namespace in relation to the architectural layers
  • Create a dependency graph for a standard matplotlib script to gain additional insight on a project's structure in relation to the user scripts
  • Take a look at the additional packages that were not a part of the matplotlib release and identify their connection with the overall architecture

The original design goals

As mentioned in Chapter 1, Getting Up to Speed, the creators of matplotlib were originally focused on building a GTK+ application for researchers and providing a command interface for the interactive plotting of data, not unlike that provided by MATLAB.

Both of these aims helped drive the development of improved abstractions for matplotlib. It was in this dual crucible that the top-level object of the rendered plots in matplotlib gained its rightful prominence—the Figure. These ideas led to various foundational objects in matplotlib, and the relationships between them ultimately provided the basis for the architecture of this library.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset