axTestClient.py 2.32 KB
Newer Older
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
42
43
44
45
46
47
48
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
#!/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 .. import SEVR, DBUG, INFO
from .. import MyAxes

D_XRANGE = None
D_YRANGE = None
D_LOGY = False
D_LOGX = False


# Class MyAxes Overwriting Matplotlib.figure.Axes
class AxTestClient(MyAxes):
  
    def declareKeywords(self):
        
        self.keywords = {'xRange': D_XRANGE,
                         'yRange': D_YRANGE}
        
        return(True)
  
    # PLOTTING -----------------------------------------------------------
    # the plotting function (need to be overwrite from child
    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)