__init__.py 4.43 KB
Newer Older
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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
42
43
from matplotlib.pyplot import show, draw, ion, ioff, clf
from matplotlib.pyplot import close as mpclose
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
44
45
46
from matplotlib.pyplot import fignum_exists, savefig
from matplotlib.axes import Axes
from matplotlib.figure import Figure
47
from matplotlib import is_interactive
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
48
from matplotlib import rcParams
49
50
from matplotlib import use

51
rcParams['backend'] = u'GTKAgg'
52

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
53
54
55
56
57
58
59
60
61
62
63
64
# myplotlib
from myData import MyData

# FORM -----------------------------------------------------------------
INFO = " > info-: "
WARN = " > warn-: "
SEVR = " > sevr-: "
DBUG = " > dbug-: "
SPCE = " > -----: "

# CONFIGURATION --------------------------------------------------------
# myFig
65
D_FIGNUM    = 0          # default figure number
66
D_FIGSIZE   = (8., 6.)   # default figure size
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
67
D_REFORMAT  = True       # default reformat value
68
69
70
D_FORMATTED = False      # default formatted value
D_RAWDATA   = MyData()   # default raw data
D_INPUTARG  = 'current'  # default Input argument
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
71
72

# myIOs
73
D_IPATH     = '../'      # default path to project
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
74
75

# print2file
76
77
D_OPATH     = 'myplotlib/img/'  # default path to ouput
D_OFORMAT   = 'png'      # default format for ouput
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
78
79

# Debug
80
D_DEBUG     = True      # default debug value
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
81
82

# GLOBAL VARIABLE ------------------------------------------------------
83
G_RAWDATAS  = {'current': MyData()}  # raw data Object
84
_G_WINDOWS = []
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
85
86
87
88
89
90
91
92
93
94
95
96

# PLOTTING CONFIGURATION -----------------------------------------------
rc('font', family='serif')
rc('font', size='22')
rc('text', usetex=True)  # need dvipng, ghostscript, and Agg
rc('lines', linewidth=1.5)
rc('lines', markersize=6)
rc('axes', linewidth=1.5)
rc('xtick.major', width=1.5, pad=10., size=10.)
rc('ytick.major', width=1.5, pad=8., size=10.)
rc('xtick.minor', width=1.5, size=5.)
rc('ytick.minor', width=1.5, size=5.)
97
rc('figure', dpi = 75.0)
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
98
99
100

# FUNCTIONS ------------------------------------------------------------
# MyAxes: Overlay on matplotlib.Axes class
101
from .myAxes import MyAxes
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
102
103

# MyFig: Overlay on matplotlib.Figure class
104
from .myFig import MyFig_base, MyFig
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
105

106
# MyFig: Overlay on matplotlib.FigureManager class
107
if rcParams['backend'] == u'TkAgg':
108
    from .myWin_TkAgg import MyWin_TkAgg as MyWin
109
elif rcParams['backend'] == u'GTKAgg':
110
    from .myWin_GTKAgg import MyWin_GTKAgg as MyWin
111
elif rcParams['backend'] == u'WXAgg':
112
    from .myWin_WXAgg import MyWin_WXAgg as MyWin
113
114
else:
    print(SEVR + "The backend you choosed is not supported interactive mode not available")
115

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
116
# myTool.*: interface functions to use myplotlib interactively
117
from .myTool import window_exists, getCurrentWindowIDs
118
from .myTool import print2file, print2screen, printListCurrentWindows
119
from .myTool import getWindow, getFigOnWindow, drawFigOnWindow, giveDataToWindow
120
from .myTool import closeWindow, closeAllWindows
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
121

122
from .test import myTest
123

124
# import the tests
125
from .test import test100
126
from .test import test200, test201, test202
127
from .test import test300, test301, test302, test303, test304, test305
128
from .test import test306, test307, test308, test309, test310
129
from .test import test400, test401, test402, test403
130
131
from .test import test500, test501, test502, test503, test504
from .test import test505, test506, test507, test508
132
from .test import test600
133

134
# the tests to run
135
testList = [test100,
136
            test200, test201, test202,
137
            test300, test301, test302, test303, test304, test305,
138
            test306, test307, test308, test309, test310,
139
            test400, test401, test402,
140
141
            test503, test506, test500, test507, test501, test502,
            test504, test505, test508,
142
143
            test600,
            ]