-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiagram.py
131 lines (104 loc) · 3.51 KB
/
diagram.py
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/python
class Diagram(object):
""" The Diagram class is used to define a diagram which can contain multiple trajectories. Different properties can be set and all of these base on the matplotlib library. """
_title = ""
_xlabel = ""
_ylabel = ""
_legend_pos = 0
_subplot_pos = 1
_legend = False
_title_visibility = False
_auto_color = True
# can contain multiple trajectories
_trajectories = dict()
def __init__(self):
""" Constructor of Diagram and default values will be initialised. """
self._title = ""
self._xlabel = ""
self._ylabel = ""
self._legend_pos = 0
self._subplot_pos = 1
self._legend = False
self._title_visibility = False
self._auto_color = True
# can contain multiple trajectories
self._trajectories = dict()
@property
def title(self):
""" Return title. """
return self._title
@property
def xlabel(self):
""" Return description of the x-axis. """
return self._xlabel
@property
def ylabel(self):
""" Return description of the y-axis. """
return self._ylabel
@property
def legend_position(self):
""" Return the position of the legend. """
return self._legend_pos
@property
def subplot_position(self):
""" Return the position of the subplot. """
return self._subplot_pos
@property
def title_visibility(self):
""" Return visibility of the title. """
return self._title_visibility
@property
def legend_visibility(self):
""" Return visibility of the legend. """
return self._legend
@property
def auto_color_allocation(self):
""" Return flag for an automatic colour allocation. """
return self._auto_color
@property
def trajectories(self):
""" Return trajectories. """
return self._trajectories
@title.setter
def title(self, title):
""" Set title. """
self._title = title
@xlabel.setter
def xlabel(self, label):
""" Set description of the x-axis. """
self._xlabel = label
@ylabel.setter
def ylabel(self, label):
""" Set description of the y-axis. """
self._ylabel = label
@legend_position.setter
def legend_position(self, pos):
""" Set position for the legend. """
self._legend_pos = pos
@subplot_position.setter
def subplot_position(self, pos):
""" Set position for a subplot. """
self._subplot_pos = pos
@title_visibility.setter
def title_visibility(self, visible):
""" Set visibility of the title. """
self._title_visibility = visible
@legend_visibility.setter
def legend_visibility(self, visible):
""" Set visibility of the legend. """
self._legend = visible
@auto_color_allocation.setter
def auto_color_allocation(self, status):
""" Set flag for an automatic colour allocation. """
self._auto_color = status
@trajectories.setter
def trajectories(self, trajectories):
""" Set trajectories. """
self._trajectories = trajectories
def add(self, trajectory, key):
""" Add a trajectory with a key that defines the trajectory. """
self._trajectories[key] = trajectory
def remove(self, key):
""" Remove a trajectory based on the key. """
if self._trajectories.has_key(key):
del self._trajectories[key]