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

Now testing the very basic usage of myplotlib for the localcase

parent 98ba5c70
Pipeline #416 failed with stage
in 1 minute and 28 seconds
from matplotlib import rcParams
# BACKEND: u'TKAgg', u'GTKAgg', u'WXAgg', u'Qt4Agg', u'MacOSX'
rcParams['backend'] = u'TKAgg'
# FONT
rcParams['font.family'] = 'serif'
rcParams['font.size'] = '22'
try:
rcParams['text.usetex'] = True # need dvipng, ghostscript, and Agg
except:
print(WARN + "I couls not set the LaTeX font sorry...")
# LINES
rcParams['lines.linewidth'] = 1.5
rcParams['lines.markersize'] = 6
# AXES
rcParams['axes.linewidth'] = 1.5
# TICKS
rcParams['xtick.major.pad'] = 10.
rcParams['xtick.major.size'] = 10.
rcParams['ytick.major.pad'] = 8.
rcParams['ytick.major.size'] = 10.
rcParams['xtick.minor.size'] = 5.
rcParams['ytick.minor.size'] = 5.
# Not compatible with old version of matplotlib
try:
rcParams['xtick.major.width'] = 1.5
rcParams['ytick.major.width'] = 1.5
rcParams['xtick.minor.width'] = 1.5
rcParams['ytick.minor.width'] = 1.5
rcParams['xtick.minor.visible'] = False
rcParams['ytick.minor.visible'] = False
except:
pass
# DPI
rcParams['figure.dpi'] = 75.0
myplotlib_server_client:
myplotlib_import_local_latex_tkagg:
script:
- apt-get update -q -y
- apt-get install python-dev python-tk -q -y
......@@ -10,6 +10,6 @@ myplotlib_server_client:
- git name-rev --name-only HEAD
- ls -l
- cd test/localhost
- ./setup_test_folder.sh
- ./setup_test_folder.sh -r latex-tkagg
- python import_test.py
- ./clean_test_folder.sh
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
# myplotlib v3.0.1,
#
# @file myAxes.py
# @author Yori 'AGy' Fournier
# @licence CC-BY-SA
#
# MyAxes class: Overlay of matplotlib Axes class
# It is done such that the user can concentrate on
# the important aspect of the figure and not the
# technical part. It consists of a constructor,
# that requires a Figure, the ratio of the xaxis over
# the yaxis, and the frame in which the figure
# should be plotted.
#
# @Class MyAxes
#
# @Constructor(self, fig, ratio, frame, +user defined kw):
#
# @section Functions
#
# - plotting: this is the overwritten function
# from Axes. It is called by it's
# parent-figure's function .plot()
#
# - formatRawData: it computes out of the rawData
# given as argument some quantities that
# are returned as a dictionary and
# become accessable for plotting.
#
# @section History
#
# v 0.0.0 - MyAxes class for the myplotlib module, consists
# of a constructor, a pltting function and
# formatRawData.
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
from myplotlib import MyAxes
from myplotlib import DBUG, SPCE, INFO, WARN, SEVR
D_XRANGE = None
D_YRANGE = None
D_LOGY = False
D_LOGX = False
# Class MyAxes Overwriting Matplotlib.figure.Axes
class AxTest(MyAxes):
# DECLARE KEYWORDS -------------------------------------------------
def declareKeywords(self):
self.keywords = {'xRange': D_XRANGE,
'yRange': D_YRANGE}
return(True)
# FORMATTING -------------------------------------------------------
def formatRawData(self, rawdata):
# give value to data a dict
# with xdata, ydata1, zdata, ydata2 ...
try:
self.data = {'xdata': [rawdata.data[0], rawdata.data[1]],
'ydata': [rawdata.data[2], rawdata.data[3]]}
except(TypeError, KeyError, IndexError):
print(SEVR + 'The Raw Data could not be formatted --> EXIT')
return(False)
if(self.fig.debug):
print(DBUG + 'I formatted the raw data!')
return(True)
def plotting(self):
xRange = self.keywords.get('xRange')
yRange = self.keywords.get('yRange')
try:
self.plot(self.data['xdata'], self.data['ydata'])
except KeyError:
print(SEVR + 'The formatting of the data was apparently wrong. --> EXIT')
return(False)
if (xRange): self.set_xlim(xRange)
if (yRange): self.set_ylim(yRange)
return(True)
# IMPORT ---------------------------------------------------------------
from myplotlib import MyFig
from axTest import AxTest
class FigTest(MyFig):
FIGSIZE = (8., 6.)
def addAxes(self):
ratio = 6. / 8. # height/width of the axes (in inch)
frame1 = [0.1, 0.1, 0.8, 0.8] # part of the fig that is available
self.add_axes(AxTest(self, ratio, frame1), "p1")
......@@ -2,3 +2,11 @@ import sys
sys.path.insert(0, './')
import myplotlib as mpl
from myIOs import readStupidData
from axTest import AxTest
from figTest import FigTest
data = readStupidData()
fig = FigTest((data,))
win = mpl.MyWin(fig)
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
# myplotlib v3.0.1,
#
# @file myIOs.py
# @author Yori 'AGy' Fournier
# @licence CC-BY-SA
#
# myIOs module: a few Input/Output functions for testing
#
# @function readStupidData
#
# create some stupid data format them as myData format
# and add then in G_RAWDATA such that they could be used
# by myAxes and myFig.
#
# @function readStupidData2
#
# same as readStupidData just with another identifier
#
# @section History
#
# v 0.0.0 - myIOs class for the myplotlib module.
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
DBUG = False
D_IPATH=''
from myplotlib import MyData
# READ STUPID DATA -----------------------------------------------------
def readStupidData(ipath=D_IPATH, *args, **kwargs):
debug = kwargs.get('debug', 0)
lrawdata = MyData()
lrawdata.name = str(ipath)
lrawdata.data = [-1., 1., 1, -1.]
if(debug):
print(DBUG + 'I read the raw data with readStupidData')
return(lrawdata)
# READ STUPID DATA 2 ---------------------------------------------------
def readStupidData2(ipath=D_IPATH, *args, **kwargs):
debug = kwargs.get('debug', 0)
lrawdata = MyData()
lrawdata.name = str(ipath)
lrawdata.data = [-1., 1., -2., 2.]
if(debug):
print(DBUG + 'I read the raw data with readStupidData2')
return(lrawdata)
......@@ -2,4 +2,5 @@
# On the virtual local host
cd myplotlib
cp ../../../.configs/tests/rconfig-latex-tkagg.py rconfig.py
find ../../../ -maxdepth 1 -name "*.py" -exec ln -s {} . \;
Supports Markdown
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