yfournier created page: create your first axes authored by Yori Fournier's avatar Yori Fournier
# Create your first Axes # The axes class
Create `mymodule/myAxes/<name of my class>.py` Create `mymodule/myAxes/<name of my class>.py`
...@@ -8,6 +8,10 @@ Create `mymodule/myAxes/<name of my class>.py` ...@@ -8,6 +8,10 @@ Create `mymodule/myAxes/<name of my class>.py`
# Import the mother class MyAxes from the local myplotlib module # Import the mother class MyAxes from the local myplotlib module
from ..myplotlib import MyAxes from ..myplotlib import MyAxes
# Here you can also import any needed module
# ex: from .. import np
# import numpy as np
# Begin of the class # Begin of the class
class axMyFirstAxes(MyAxes): class axMyFirstAxes(MyAxes):
...@@ -58,4 +62,23 @@ class axMyFirstAxes(MyAxes): ...@@ -58,4 +62,23 @@ class axMyFirstAxes(MyAxes):
# Returning True or False is not optional # Returning True or False is not optional
return(True) return(True)
```
# Linking the new class to the module
Now that the axes class is created we just need to link it to the module.
To do so you need to add the following line in `mymodule/myAxes/__init__.py`
```python
from axMyFirstAxes import AxMyFirstAxes
```
the module `mymodule` import by default all axes in the sub-module `myAxes`, so you just need
to tell `myAxes` to load the class `AxMyFirstAxes` from the file `axMyFirstAxes`.
# Using the axes
Now you are ready to play with your new axes:
```python
from mymodule import *
data = ...
fig = FigOneAxes2D((data,), AxMyFirstAxes)
win = MyWin(fig)
``` ```
\ No newline at end of file