Commit 0163fafd authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch 'begin-tuto' into 'master'


See merge request !4
parents 4824037c fc5058c5
Get started
for the online version see
A. Install the template module
# Summary
1. [Install the module mypltemplate](
2. [Plotting some Examples](
3. [Examples](
# 1. Install the module mypltemplate
> **NOTES:** STEP 3 has two version with and without an account at
## STEP 1: download source
download the source of the module mypltemplate:
- [zip](
- [tar.gz](
## STEP 2: extract and rename the module
you can rename `mypltemplate` to any name you whish.
> **NOTES:** for the exemple we rename it to `mymodule` in the directory `/home/user/src/`
> (python requires that module name should be only letters)
## STEP 3: Clone myplotlib from **(with account at**
in `/home/user/src/mymodule`:
git --branch tools
## STEP 3: download source **(without an account at**
download source of the module myplotlib
- [zip](
- [tar.gz](
extract and rename like `/home/user/src/mymodule/myplotlib`
## STEP 4: testing `myplotlib`
in `/home/user/src/mymodule/`
python2.7 -m myplotlib -t
This will execute a series of tests, they should all be successful.
## STEP 5: Enjoy!
Now you can start to enjoy the power of `myplotlib`
# 2. Plotting some Examples
## STEP 1: launch python2.7
## STEP 2: Import the module.
from mymodule import *
This imports all variables, functions and classes from `mymodule/`
## STEP 3: Open and Access some data
The template modules has some dummy data for demonstration in `mymodule/data`
This data are of two type:
- some **structured datasets** (run1.txt, run2.txt, ...)
- some **database-like datasets** (serie1.txt, serie2.txt)
In python (this is a general remark) it exists two powerful objects for
storing and accessing these types of data.
- for **structured datasets** the python **dictionaries** are suitable (see [doc](
- for **database-like datasets** the **numpy.recarray** are the perfect tool (see [doc](
In `mymodule/myIOs` are two files containing the functions `readRun`, and `readSeries`
- the function `readRun` reads a run-text-file (structured data set) and stores the information into a python dictionary.
- the function `readSeries` reads a series-text-file (database data set) and stores the data into a numpy recarray.
Both function returns the data container of myplotlib, `MyData`
# READ Some data
run1 = readRun('./mymodule/data/serie1/run1.txt')
now you can now type
>>> <mymodule.myplotlib.myData.MyData instance at ...>
As you can see the object `run1` is an instance of type `MyData`. The `...` shows the address of the instance in the memory.
This identifier is unique (again this is a general remark for python).
Now you can access the name of the run, the vaue of input1 or the matrix of the results by simply typing:
## STEP 4: Visualising the data
In `mymodule/myAxes` are a few examples of axes classes.
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`.
We will start with the class `AxResults` (see ``)
In order to plot the axes we need to integrate it into a figure.
For the comfort of the user, `myplotlib` comes with a few standard classes like `FigOneAxes3D` (see myplotlib/mytools/
This class is build over `MyFig` (compatible with any `MyAxes`) and can be used as a container
for a single `MyAxes` instances.
We can now create a figure `fig` of type `FigOneAxes3D` with the
dataset `(run1,)` given to the axes class `AxResults`.
# Create a figure
fig = FigOneAxes3D((run1,), AxResults)
you can now type:
>>> <mymodule.myplotlib.mytool.figOneAxes3D.FigOneAxes3D at ...>
We can also access the axes:
>>> [<mypltemplate.myAxes.axResults.AxResults at ...>]
or even store the axes into a variable:
ax = fig.get_axes()[0]
>>> <mypltemplate.myAxes.axResults.AxResults at ...>
The object `fig` has (alike any `MyFig` instance) a function `plot()`
The `plot` function will call all `plotting` function of all axes contained in `fig`.
> For this example only `ax.plotting()`.
The `plotting` function will act on some attributes of ax.
> For instance it will change the label.
# The label of the axes before plotting
>>> u''
# CALL the PLOT procedure
# The label after plotting
>>> u'${\\rm x}~[{\\rm m}]$'
As you can see any part of the object can be access.
for more details see matplotlib documentation (see [doc](
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,
containing a canvas.
- The **window** has some buttons like close, reduce and so one...
- 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).
# Create a window where the figure is shown
win = MyWin(fig)
This should produce a window on which `fig` should be plotted.
# 3. Examples
## What you just did
# Import the module
from mymodule import *
# Read some data
run1 = readRun('./mymodule/data/serie1/run1.txt')
# Create a figure
fig = FigOneAxes3D((run1,), AxResults)
# Create a window where the figure is shown
win = MyWin(fig)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment