|
|
# Summary
|
|
|
|
|
|
1. [Concept](#concept)
|
|
|
2. [The class AxMyFirstAxes](#the-class-axmyfirstaxes)
|
|
|
2. [The class FigMyFirstFigure](#the-class-figmyfirstfigure)
|
|
|
3. [Linking the class to the module](#linking-the-new-class-to-the-module)
|
|
|
4. [Using the axes](#using-the-axes)
|
|
|
4. [Using the figure](#using-the-figure)
|
|
|
|
|
|
# Concept
|
|
|
|
... | ... | @@ -16,30 +16,24 @@ alike in matplotlib a plot is composed of four type of objects: |
|
|
3. **The figure** (an empty object that contains an array of axes)
|
|
|
4. **The axes** (This is the core of the plot)
|
|
|
|
|
|
We naturally start with the **axes**.
|
|
|
> **NOTE**: If you have not read yet the page about axes you should start [there](Create your first axes)
|
|
|
|
|
|
An axes is composed of two **axis**, two **labels**, one **title** and a bunch of **artists**.
|
|
|
- an **axis**: has ticks (minors and majors), ticklabels (the numbers) and limits
|
|
|
- the **labels** and **title** are just text objects
|
|
|
- the **artists** are everything you may draw on the axes: lines, polygones, images, text, surfaces... (see [doc](http://matplotlib.org/users/artists.html#axes-container))
|
|
|
It is always a good idea to design figures, the sub-module mytools of myplotlib offers a few standard figure classes
|
|
|
that are very practical for testing and fast development purposes but at the end you may want to access some more
|
|
|
specific features.
|
|
|
|
|
|
In **myplotlib** we add two intrinsic functionalities to an axes.
|
|
|
The main idea behind **myplotlib** is the independence of the axes.
|
|
|
As just mentioned a figure is a container for axes. Indeed a figure may contain a few axes. This is practical
|
|
|
for comparison, completeness, or user specific legends.
|
|
|
|
|
|
> *An axes should know how to extract the relevant information it needs and how to represent them on the screen.*
|
|
|
Indeed in matplotlib colorbars and legends are axes. In myplotlib too.
|
|
|
|
|
|
As a results a MyAxes instance (the axes in myplotlib) has two additional functions:
|
|
|
- **formatRawData**: the function that extract the information (tech: produce a self.data object).
|
|
|
- **plotting**: the function that represent these data on the screen (tech: produce artists in the axes container).
|
|
|
The difference is that in myplotlib figures have a one additional feature: **user-specific keywords!**
|
|
|
|
|
|
keywords are very practical you can access them from any axes functions. These are the global variables of the figure.
|
|
|
one more advantage of keywords they can, passed to the figure while creating it and can be modified on the fly with
|
|
|
the function update.
|
|
|
|
|
|
If you look at [myplotlib/myAxes.py](https://gitlab.aip.de/yfournier/myplotlib/blob/tools/myAxes.py)
|
|
|
you will remark that these two functions are empty. That is the power of object oriented programming.
|
|
|
`MyAxes` is a container class that fits into a framework, it is compatible with all the functionalities of matplotlib.
|
|
|
So now you have the freedom of specialising this **base class** to any purpose you wish,
|
|
|
ensuring that you can enjoy the full power of matplotlib.
|
|
|
|
|
|
Now we will see how to overwrite the **base class** `MyAxes` with a new class that we will call `AxMyFirstAxes`.
|
|
|
To overwrite a class you just need to overwrite these two empty functions and actually do something.
|
|
|
|
|
|
# The class AxMyFirstAxes
|
|
|
|
... | ... | |