The current matplotlib architecture

The current matplotlib architecture revolves around the operations that are necessary for the users to create, render, and update the Figure objects. Figures can be displayed and interacted with via common user interface events such as the keyboard and mouse inputs. This layer of interaction with common user interface is called the backend layer. A Figure needs to be composed of multiple objects that should be individually modifiable, but it should be implemented in such a way that it has a positive and predictable impact on the other aspects of the Figure. This logical layer is responsible for the abstraction of each visual component that one sees in a Figure. Due to its highly visual nature, this layer was identified as the more general concept of creating visual art and is thus referred to as the artist layer. Lastly, the Figure needs to support programmatic interaction and provide the users with the ability to manipulate Figures with a syntax that is as clean and intuitive as possible. This is called the scripting layer.

The following figure shows the relation between the three layers of matplotlib architecture (backend, artist, and scripting):

The current matplotlib architecture

The backend layer rests at the bottom of the matplotlib architecture and it only knows about its own interfaces. The subsequent layers at the top of the stack know only about themselves and the layers below. Thus, complexities are properly isolated to the higher levels. In describing this, we are taking some liberties with the simplification that we've generated, which is a small sacrifice that was made to help clarify the roles of the layers. We will cover each layer of this stack in detail in the following sections. We will provide examples, references to code, and diagrams. Part of this will include revealing the complexity behind the initial sketch that you just saw.

As we explore the depths of matplotlib in the following sections, it might be helpful to keep a mental placeholder for the layers as they relate to data and the Figure object for a given plot in the following way:

  • The user creates either the data that he/she wants to plot or the functions that generate this data
  • This data is either created or loaded in the scripting layer
  • The data is transformed into various objects in the artist layer; it is adjusted as scripted
  • These objects are then rendered by the backend, which ultimately provides the configured toolkit with the raw data necessary to place an image on the toolkit's canvas

Let's explore this in more detail now, starting from the bottom—the backend layer.

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

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