yfournier created page: create your first figure authored by Yori Fournier's avatar Yori Fournier
...@@ -54,7 +54,7 @@ from ..myplotlib import MyFig ...@@ -54,7 +54,7 @@ from ..myplotlib import MyFig
# Begin of the class # Begin of the class
class figMyFirstFigure(MyFig): class figMyFirstFigure(MyFig):
# The function where you declare the user-defined keywords # The function where you declare the user-defined keywords (optional)
def declareKeywords(self): def declareKeywords(self):
# The size of the figure can be also defined here (optional) # The size of the figure can be also defined here (optional)
...@@ -62,10 +62,10 @@ class figMyFirstFigure(MyFig): ...@@ -62,10 +62,10 @@ class figMyFirstFigure(MyFig):
# the name of the dict is not optional. # the name of the dict is not optional.
self.keywords = {'<name of the keyword>': <default value>, self.keywords = {'<name of the keyword>': <default value>,
'xunit': 'years', 'xunit': 'years',
'withAnotation': False, 'withAnotation': False,
'twoColumn': False, 'twoColumn': False,
...} ...}
# The function where you tell the figure where tu plot what # The function where you tell the figure where tu plot what
...@@ -75,7 +75,7 @@ class figMyFirstFigure(MyFig): ...@@ -75,7 +75,7 @@ class figMyFirstFigure(MyFig):
ratioAxes1 = 6./8. ratioAxes1 = 6./8.
frameAxes1 = [0, 0, 0.5, 1.0] # [x0, y0, width, height] in unit of figwidth and figheight frameAxes1 = [0, 0, 0.5, 1.0] # [x0, y0, width, height] in unit of figwidth and figheight
ratioAxes2 = 6./8. ratioAxes2 = 6./8.
frameAxes2 = [0.5, 0.0, 0.5, 1.0] frameAxes2 = [0.5, 0.0, 0.5, 1.0]
self.add_axes(AxMyFirstAxes(self, rationAxes1, frameAxes1)) self.add_axes(AxMyFirstAxes(self, rationAxes1, frameAxes1))
...@@ -83,20 +83,20 @@ class figMyFirstFigure(MyFig): ...@@ -83,20 +83,20 @@ class figMyFirstFigure(MyFig):
``` ```
# Linking the new class to the module # Linking the new class to the module
Now that the axes class is created we just need to link it to the module. Now that the figure 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` To do so you need to add the following line in `mymodule/myFigures/__init__.py`
```python ```python
from axMyFirstAxes import AxMyFirstAxes from figMyFirstFigure import FigMyFirstFigure
``` ```
the module `mymodule` import by default all axes in the sub-module `myAxes`, so you just need the module `mymodule` import by default all figures in the sub-module `myFigures`, so you just need
to tell `myAxes` to load the class `AxMyFirstAxes` from the file `axMyFirstAxes`. to tell `myFigures` to load the class `FigMyFirstFigure` from the file `figMyFirstFigure`.
# Using the axes # Using the figure
Now you are ready to play with your new axes: Now you are ready to play with your new figure:
```python ```python
from mymodule import * from mymodule import *
data = ... data = ...
fig = FigOneAxes2D((data,), AxMyFirstAxes) fig = FigMyFirstFigure((data, data))
win = MyWin(fig) win = MyWin(fig)
``` ```
\ No newline at end of file