yfournier created page: get started authored by Yori Fournier's avatar Yori Fournier
...@@ -112,69 +112,79 @@ run1.data['results'] ...@@ -112,69 +112,79 @@ run1.data['results']
``` ```
---- STEP 4: Visualising some RUN data ## STEP 4: Visualising the data
In "mymodule/myAxes" are a few files starting with ax these contain classes of Axes. In `mymodule/myAxes` are a few examples of axes classes.
These classes are build over a general class MyAxes (from myplotlib). The class MyAxes These classes are build over a general class `MyAxes` (from myplotlib). The class `MyAxes`
is build such that it can be used with any user defined class build on MyFig. is build such that it can be used with any user-defined class build on `MyFig`.
We will start with the class AxResults (see axResults.py) We will start with the class `AxResults` (see `axResults.py`)
In order to plot the Axes we need to integrate it into a Figure. In order to plot the axes we need to integrate it into a figure.
For the confort of the user, myplotlib comes with a few standard classes like FigOneAxes3D. For the comfort of the user, `myplotlib` comes with a few standard classes like `FigOneAxes3D` (see myplotlib/mytools/figOneAxes3D.py).
This class is build over MyFig (compatible with any MyAxes) and can be used as a container This class is build over `MyFig` (compatible with any `MyAxes`) and can be used as a container
for a single MyAxes. for a single `MyAxes` instances.
We can now create a figure fig an instance of FigOneAxes3D with the We can now create a figure `fig` of type `FigOneAxes3D` with the
dataset (run1,) given to the class AxResults. dataset `(run1,)` given to the axes class `AxResults`.
>>> # Create a figure to show the data ```python
>>> fig = FigOneAxes3D((run1,), AxResults) # Create a figure
fig = FigOneAxes3D((run1,), AxResults)
```
you can now type: you can now type:
>>> fig ```python
<mymodule.myplotlib.mytool.figOneAxes3D.FigOneAxes3D at ...> fig
>>> <mymodule.myplotlib.mytool.figOneAxes3D.FigOneAxes3D at ...>
```
We can also access the axes: We can also access the axes:
>>> fig.get_axes() ```python
[<mypltemplate.myAxes.axResults.AxResults at ...>] fig.get_axes()
>>> [<mypltemplate.myAxes.axResults.AxResults at ...>]
```
or even store the axes into a variable: or even store the axes into a variable:
>>> ax = fig.get_axes()[0] ```python
>>> ax ax = fig.get_axes()[0]
<mypltemplate.myAxes.axResults.AxResults at ...> ax
>>> <mypltemplate.myAxes.axResults.AxResults at ...>
The FigOneAxes3D has (alike any MyFig instance) a function plot() ```
The plot function will call all plotting function of all axes contained in FigOneAxes3D.
In that case just one ax.plotting.
The plotting function will act on some attributes of the AxResults ax.
It will change the label for example.
>>> # The label of the axes before plotting The object `fig` has (alike any `MyFig` instance) a function `plot()`
>>> ax.get_xlabel() The `plot` function will call all `plotting` function of all axes contained in `fig`.
u'' > For this example only `ax.plotting()`.
The `plotting` function will act on some attributes of ax.
> For instance it will change the label.
>>> # CALL the PLOT procedure ```python
>>> fig.plot() # The label of the axes before plotting
ax.get_xlabel()
>>> u''
>>> # The label after plotting # CALL the PLOT procedure
>>> ax.get_xlabel() fig.plot()
u'${\\rm x}~[{\\rm m}]$'
As you can see any part of the object can be access for more details # The label after plotting
see matplotlib documentation (http://matplotlib.org/api/axes_api.html) ax.get_xlabel()
>>> u'${\\rm x}~[{\\rm m}]$'
```
As you can see any part of the object can be access.
for more details see matplotlib documentation [doc](http://matplotlib.org/api/axes_api.html)
Now it is time to show the data set on the screen. To do so myplotlib Now it is time to show the data set on the screen. To do so `myplotlib`
comes with a class called MyWin. This class will create a window, comes with a class called `MyWin`. This class will create a window,
containing a canvas. containing a canvas.
- The window has some buttons like close, reduce and so one... - The **window** has some buttons like close, reduce and so one...
- The canvas can be seen as a white sheet of paper - The **canvas** can be seen as a white sheet of paper
on which you will draw a Figure (only one figure can be drawn on a canvas). on which you will draw a figure (only one figure can be drawn on a canvas).
>>> # Create a window where the figure is shown ```python
>>> win = MyWin(fig) # Create a window where the figure is shown
win = MyWin(fig)
This should produce a window on which fig should be plotted. ```
\ No newline at end of file This should produce a window on which `fig` should be plotted.
\ No newline at end of file