__init__.py 5.01 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from matplotlib import use

#use('GTKAgg')

rcParams['backend'] = u'WXAgg'

if rcParams['backend'] == u'GTKAgg':
    print(" > info-: You ask to use GTKAgg")
    try:
        from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
        from matplotlib.backends.backend_gtkagg import FigureManagerGTKAgg as FigureManager
#        FigureFrameWxAgg = None
#        _create_wx_app = None
    except:
        print(" > sevr-: Apparently the backend GTKAgg is not available")
        exit(1)
        
elif rcParams['backend'] == u'WXAgg':
    print(" > info-: You ask to use WXAgg")
    try:
        from matplotlib.backends.backend_wxagg import FigureFrameWxAgg
        from matplotlib.backends.backend_wx import _create_wx_app
        from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
        from matplotlib.backends.backend_wx import FigureManagerWx as FigureManager
    except:
        print(" > sevr-: Apparently the backend WXAgg is not available")
        exit(1)
        
elif rcParams['backend'] == u'TkAgg':
    print(" > info-: You ask to use TkAgg")
    try:
        from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg as FigureCanvas
        from matplotlib.backends.backend_tkagg import FigureManagerTkAgg as FigureManager
    except:
        print(" > sevr-: Apparently the backend TkAgg is not available")
        exit(1)
else:
    print(" > sevr-: You asked a backend that is not yet supported.")
    print(" > -----: " + str(rcParams['backend']))
88

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
89
90
91
92
93
94
95
96
97
98
99
100
# myplotlib
from myData import MyData

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

# CONFIGURATION --------------------------------------------------------
# myFig
101
D_FIGNUM    = 0          # default figure number
102
103
104
105
106
D_FIGSIZE   = (8., 6.)   # default figure size
D_REFORMAT  = True       # default reformat value
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
107
108

# myIOs
109
D_IPATH     = '../'      # default path to project
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
110
111

# print2file
112
113
D_OPATH     = 'myplotlib/img/'  # default path to ouput
D_OFORMAT   = 'png'      # default format for ouput
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
114
115

# Debug
116
D_DEBUG     = True      # default debug value
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
117
118

# GLOBAL VARIABLE ------------------------------------------------------
119
G_RAWDATAS  = {'current': MyData()}  # raw data Object
120
_G_WINDOWS = []
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
121
122
123
124
125
126
127
128
129
130
131
132

# 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.)
133
rc('figure', dpi = 75.0)
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
134
135
136
137
138
139
140
141
142
143
144

# FUNCTIONS ------------------------------------------------------------
# MyAxes: Overlay on matplotlib.Axes class
from myAxes import MyAxes

# MyIOs.*: input/output function for testing
from myIOs import readStupidData, readStupidData2

# MyFig: Overlay on matplotlib.Figure class
from myFig import MyFig

145
146
147
# MyFig: Overlay on matplotlib.FigureManager class
from myWin import MyWin

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
148
# myTool.*: interface functions to use myplotlib interactively
149
150
151
from myTool import print2file, print2screen, printListCurrentWindows
from myTool import getWindow, getFigOnWindow, drawFigOnWindow
from myTool import closeWindow, closeAllWindows
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
152
153
154
155
156
157

# MyFig4Test: Overlay of Figure for testing
from myFig4Test import MyFig4Test

# some plotting routine for testing
from myPlot4Test import somePlottingRoutine
158
159

from test import myTest
160
from test import test400, test300, test401, test402
161

162
testList = [test400, test300, test401, test402]