Changes
Page history
yfournier created page: create your first figure
authored
Feb 16, 2017
by
Yori Fournier
Hide whitespace changes
Inline
Side-by-side
create-your-first-figure.md
View page @
35599396
...
...
@@ -54,7 +54,7 @@ from ..myplotlib import MyFig
# Begin of the class
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
):
# The size of the figure can be also defined here (optional)
...
...
@@ -62,10 +62,10 @@ class figMyFirstFigure(MyFig):
# the name of the dict is not optional.
self
.
keywords
=
{
'
<name of the keyword>
'
:
<
default
value
>
,
'
xunit
'
:
'
years
'
,
'
withAnotation
'
:
False
,
'
twoColumn
'
:
False
,
...}
'
xunit
'
:
'
years
'
,
'
withAnotation
'
:
False
,
'
twoColumn
'
:
False
,
...}
# The function where you tell the figure where tu plot what
...
...
@@ -75,7 +75,7 @@ class figMyFirstFigure(MyFig):
ratioAxes1
=
6.
/
8.
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
]
self
.
add_axes
(
AxMyFirstAxes
(
self
,
rationAxes1
,
frameAxes1
))
...
...
@@ -83,20 +83,20 @@ class figMyFirstFigure(MyFig):
```
# 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/my
Ax
es/__init__.py`
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/my
Figur
es/__init__.py`
```
python
from
ax
MyFirst
Axes
import
Ax
MyFirst
Axes
from
fig
MyFirst
Figure
import
Fig
MyFirst
Figure
```
the module
`mymodule`
import by default all
ax
es in the sub-module
`my
Ax
es`
, so you just need
to tell
`my
Ax
es`
to load the class
`
Ax
MyFirst
Axes
`
from the file
`
ax
MyFirst
Axes
`
.
the module
`mymodule`
import by default all
figur
es in the sub-module
`my
Figur
es`
, so you just need
to tell
`my
Figur
es`
to load the class
`
Fig
MyFirst
Figure
`
from the file
`
fig
MyFirst
Figure
`
.
# Using the
axes
Now you are ready to play with your new
axes
:
# Using the
figure
Now you are ready to play with your new
figure
:
```
python
from
mymodule
import
*
data
=
...
fig
=
Fig
OneAxes2D
((
data
,),
AxMyFirstAxes
)
fig
=
Fig
MyFirstFigure
((
data
,
data
)
)
win
=
MyWin
(
fig
)
```
\ No newline at end of file