Commit e89466d0 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch 'dev' into 'master'

Setting the new master

See merge request !74
parents 9d297e9e 4ded1528
Pipeline #721 failed with stage
config.py
build
dist
myplotlib.egg-info
*.pyc
.install_with_setup:
before_script:
- python3 --version
- python3 -m pip --version
- python3 -m venv --version
- apt-get update -q -y
- apt-get install python3 python3-dev python3-tk -q -y
- python3 -m venv --python=python3.6 mplenv
- . mplenv/bin/activate
- pip install matplotlib
dummy:
script:
- ls -l
- python --version
- which python
- which python3
- which pip
.myplotlib_import_local_latex_tkagg:
script:
- ls -l
- cd test/localhost
- ./setup_test_folder.sh -r latex-tkagg
- python3 import_test.py
- python3 -m tests
- python3 -m tutorials
- ./clean_test_folder.sh
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
* Introduction
** Motivation
As a scientist you need to produce plots.
The question is how to plot?
You usually face large data sets
That you want to process in different manner
and plot one aspect of it.
You also may want to compair a single aspect
of different data set, or different aspect of
a single data set.
And you may want to do in a fast and interactive
manner, but most of it, you want to control what
you do and be sure of what you plot.
Finally, after spending time on a single plot
you want to be able to use it for various data sets,
make it pretty, and be able to keep track of your
plots, reusing them and having a consistency between
version of the plot. Processing large dataset with
the same ploting procedure. And also you don't want
to rethink tomuch when you come back after a week or
two how you did that plot.
These are the basic reason of myplotlib.
myplotlib allows you to design a plot, that consist
of only one single file that can be combined with any
other plot, or alone.
This plot contains it own data processing and can be
used for any data you provide.
It can be called interactively for comparing, and reads
only one the large raw data set. In case the raw data
processing is long you can also prevent extra computation.
After comparing the data, you may also want to roduce a
large amount of files, that plot the same things for
various datasets. The script mode is designed for that.
You can use myplotlib from command line and give it
arguments.
In case you are fine with a plot, but after some time
your recognise that some change are required, because
your plot is in a unique file indpendntly how many time
you use it in various configurations, any changes will
be spread, allowing fast and consistent corrections.
to summarize myplotlib can:
- interactive mode
- script mode
- consistent corrections
- versatile dataset
- full user control on IOs and data processing
making it fast and safe
** Organisation of this document
* Requirements
- matplotlib
- texlive-latex-extra (latex package for tex fonts in plots)
- dvipng (dvi to png for print to file)
* Structure of the Package
** The subpackages
** The class structure
An object MyFig is an object-plot made of MyAxes objects which
represents the plots.
In order to make a new object-plot, you should create a class MyNewFig
being inheritant from MyFig, at least 3 functions: __init__,
printDebug, plot and update. like:
* Exemples
** The MyFig object
# ======== myNewFig.py ================================================
# Import --------------------------------------------------------------
from interface import *
# Default values ------------------------------------------------------
dMyNewParam = None
dfigsize=(<width in inches>, <height in inches>)
# CLASS MyNewFig ------------------------------------------------------
class MyNewFig(MyFig):
# Constructor -------------------------------------------------------
def __init__(self, figsize=dfigsize, # needed
myNewParam=dMyNewParam, <some args>, # optional
*args, **kwargs): # needed
# Parent constructor
MyFig.__init__(self, figsize=dfigsize, *args, **kwargs)
# add your parameters
# i.e.: self.myNewParam = myNewParam
# Print debug function ----------------------------------------------
# This function is called when debug=True
def printDebug(self):
# print some stuff
print('\n'+INFO+"MyNewFig: myNewParam = "+str(self.myNewParam))
# Plot function -----------------------------------------------------
def plot(self):
ratio=6./8. # this is the aspect ratio of the MyAxes object
# frame is the rect of the area which will be covered by the
# MyAxes object. Including axis title...
frame=[<posx>, <posy>, <width>, <height>]
# frame=[0,0,1,1] # for a single plot.
# create at least one MyAxes with MyPrettyAxes being inheretied
# from MyAxes.
ax1 = myplots.MyPrettyAxes(self, ratio, frame)
ax2 = myplots.MyOtherPrettyAxes(self, ratio, frame)
# ...
# add the axes
self.add_axes(ax1)
self.add_axes(ax2)
# plot the axes
ax1.plotting()
ax2.plotting()
# Update function ---------------------------------------------------
def update(self, # nedded
myNewParam=dMyNewParam, <some args>, # optional
*args, **kwargs): # needed
MyFig.update(self, *args, **kwargs)
# This is important to redraw the function, in the same fig.
self.myNewParam = myNewParam
# =====================================================================
** The MyAxes object
# ======== myplots/myNewAxes.py =======================================
# Import --------------------------------------------------------------
from interface.myplots import *
# CLASS MyNewAxes------------------------------------------------------
class MyNewAxes(MyAxes):
# Constructor -------------------------------------------------------
def __init__(self, fig, ratio, frameRect, **kwargs):
# Parent constructor
MyAxes.__init__(self, fig, ratio, frameRect, **kwargs)
# extra parameters
self.fig = fig
self.MyNewParam = self.fig.MyNewParam
# Plotting function -------------------------------------------------
def plotting(self):
# print some stuff if you need
# print...
# read some data if you need
# data=readData(self.MyNewParam)
# this way is also nice
# self.readData()
# compute some stuff if you need
# x, y = computeData(data)
# xlabel, ylabel
xlabel=r'X Axis'
ylabel=r'Y Axis'
self.xaxis.set_label_text(xlabel)
self.yaxis.set_label_text(ylabel)
# plot stuff
self.plot(x,y)
# put some limits
self.set_xlim([-1, 1])
self.set_ylim([-1, 1])
# other pretty stuff ...
# =====================================================================
** Usage
# import interface
>> from interface import *
# to show the fig on the screen
>> screen(MyNewFig, MyNewParam=12.)
# to print it into a file
>> print2file(MyNewFig, 'myNewFig.png')
* Test
to test just type:
python -m myplotlib
it will run a test should not show any error.
* TODOS
** TODO make beter test series with test repport
** TODO make a get opt for the testing to run various test series
** DONE reload the data only when needed
CLOSED: [2016-02-10 mer. 11:31]
** DONE Make a GIT repo
CLOSED: [2016-12-28 Wed 20:19]
# Summary
1. [Motivation](#1-motivation)
2. [The Power of myplotlib](#2-the-power-of-myplotlib)
3. [Install from source](#3-install-from-source-without-an-account-at-gitlabaipde)
4. [Install with git](#4-install-with-git-with-an-account-at-gitlabaipde)
5. [Get started](#5-get-started)
# 1. Motivation
>>>
As a scientist you need to produce plots.
The question is how to plot?
>>>
**plot and compare subsets of large data sets**
>>>
You usually face large data sets,
which you want to process in different manner
to extract and plot a single aspect of this data set.
But you may also want to compare a single aspect
of different data sets, or on the contrary different aspects
of a single data set.
>>>
**plot fast and interactively**
>>>
And you may want to do in a fast and interactive
manner.
>>>
**be sure what you plot**
>>>
But the most important for a scientist is to control what
you do and be sure of what you plot.
>>>
**clear and transparent way to plot**
>>>
Plots are the key value of your work.
You want to spend time on the quality of the content and form.
Not on the technical aspect of how to plot what.
>>>
**reuse, improve, and combine your plots**
>>>
After spending time on designing the content and the
form of a single plot you want to be able to use it for
various data sets without loosing consistence between
versions of the plot.
>>>
**keep track of your plots over long periods**
>>>
Finally, when you come back on some former work,
you don't want to rethink about the technique,
you want to start from the same point as before
from another point of view.
>>>
**These are the basic features of `myplotlib` and much more.**
# 2. The power of `myplotlib`
`myplotlib` allows you to design a plot, that consist
of a single file.
It can then plotted alone or combined with any other plot.
This plot contains it own data processing method and
can be used for any compatible raw data you provide.
A plot can be called interactively from a python interpreter,
or from the command line.
The same plot can be drawn on screen or directly in a file
making sure that what you see is what you get.
Producing files of the same aspect of large number of
data sets is possible thanks to the scripting mode.
Because a plot is in a unique file, any changes will
be spread, allowing fast and consistent corrections.
## `myplotlib` can:
- interactive mode
- script mode
- consistent corrections
- versatile dataset
- full user control on IOs and data processing
making it fast and safe
# 3. Install from source **(without an account at gitlab.aip.de)**
### STEP 1: download source of the module myplotlib
- [zip](https://gitlab.aip.de/yfournier/myplotlib/repository/archive.zip?ref=v3.0.1a)
- [tar.gz](https://gitlab.aip.de/yfournier/myplotlib/repository/archive.tar.gz?ref=v3.0.1a)
extract and rename like `/home/user/src/python/myplotlib`
### STEP 2: Install
Set the python path
```
export PYTHONPATH="/home/user/src/python/"
```
Create your config file (in `/home/user/src/python/myplotlib/`)
```
cp config-default.py config.py
```
### STEP 3: testing
in `/home/user/src/python/`
```
python2.6 -m myplotlib.__main__ -t
python2.7 -m myplotlib -t
python3 -m myplotlib -t
```
This will execute a series of tests, they should all be successful.
> **REMARK**: If you get some errors, try the minimal configuration: replace config.py with myplotlib/.configs/minimal-config.py
# 4. Install with git (with an account at gitlab.aip.de)
> comming soon
# 5. Get started
- [first plot](https://gitlab.aip.de/yfournier/myplotlib/wikis/how-to-use-interactively)
- [how to use myplotlib](https://gitlab.aip.de/yfournier/myplotlib/wikis/how-to-use-myplotlib)
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
# myplotlib v0.0.0,
#
# @file __init__.py
# @author Yori 'AGy' Fournier
# @licence CC-BY-SA
#
# Import and Configuration file for myplotlib
#
# @section Import
#
# myplotlib is base on matplotlib therefore it requires
# Figure and Axes as main classes and a few further functions.
#
# @section Config
#
# Default value for user parameters
# and configuration for the default plotting
#
# @section Module Import
#
# Import of myplotlib classes and function
#
# @section History
#
# v 0.0.0 - __init__.py file for the myplotlib module
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
import os as os
import numpy as np
# matplotlib
from matplotlib.pyplot import figure
from matplotlib.pyplot import rc
from matplotlib.pyplot import show, draw, ion, ioff, clf, close
from matplotlib.pyplot import fignum_exists, savefig
from matplotlib.axes import Axes
from matplotlib.figure import Figure
from matplotlib import rcParams
# myplotlib
from myData import MyData
# FORM -----------------------------------------------------------------
INFO = " > info-: "
WARN = " > warn-: "
SEVR = " > sevr-: "
DBUG = " > dbug-: "
SPCE = " > -----: "
# CONFIGURATION --------------------------------------------------------
# myFig
D_FIGNUM = 0 # default figure number
D_FIGSIZE = (8., 6.) # default figure size
D_REFORMAT = True # default reformat value
D_RAWDATA = MyData() # default raw data
D_INPUTARG = 'current' # default Input argument
# myIOs
D_IPATH = '../' # default path to project
# print2file
D_OPATH = 'myplotlib/img/' # default path to ouput
D_OFORMAT = 'png' # default format for ouput
# Debug
D_DEBUG = True # default debug value
# GLOBAL VARIABLE ------------------------------------------------------
G_RAWDATAS = {'current': MyData()} # raw data Object
# PLOTTING CONFIGURATION -----------------------------------------------