|
|
# Concept
|
|
|
|
|
|
**myplotlib** is an interface between you and the great functionality of matplotlib.
|
|
|
|
|
|
As such it naturally inherit a lot of the structures from matplotlib:
|
|
|
alike in matplotlib a plot is composed of four type of objects:
|
|
|
1. **The window** (that contains the buttons, and handle events)
|
|
|
2. **The canvas** (the sheet of paper where you draw the figure)
|
|
|
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**.
|
|
|
|
|
|
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))
|
|
|
|
|
|
In **myplotlib** we add two intrinsic functionalities to an axes.
|
|
|
The main idea behind **myplotlib** is the independence of the axes.
|
|
|
|
|
|
> *An axes should know how to extract the relevant information it needs and how to represent them on the screen.*
|
|
|
|
|
|
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).
|
|
|
|
|
|
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 axes class
|
|
|
|
|
|
Create `mymodule/myAxes/<name of my class>.py`
|
... | ... | |