3 class PlotObject(object):
15 self.vectors is a multidimensional array:
21 2 curves in a x,y plot are:
22 [[[x1],[y1]],[[x2],[y2]]]
25 [[[1,2,3,4],[10,20,30,40]],[[3,6,9,12],[30,60,90,120]]]
26 x1 = self.vectors[0][0]
27 y1 = self.vectors[0][1]
28 x2 = self.vectors[1][0]
29 y2 = self.vectors[1][1]
34 self.units is simpler. for each plot with N axes (x,y,z...) only N labels
35 can be made, regardless of the number of superimposed plots
36 so units for the double plot above is: [unitx, unity]
43 xaxes and yaxes directions. 0, 0 means the common +X=right, +Y=top directions
49 self.title = '' #title
52 styles: defines what is the style of the current plots. If undefined or None, it is line plot.
53 If an element of the list is 'scatter', the corresponding dataset
54 is drawn with scattered points and not a continuous line.
59 colors: define what is the colour of the current plots
63 def add_set(self, x, y):
65 Adds an x, y data set to the vectors.
67 self.vectors.append([])
68 self.vectors[-1].append(x)
69 self.vectors[-1].append(y)
71 def remove_set(self, whichset):
75 #TODO: do we need 'waste' here?
76 waste = self.vectors.pop(whichset)
78 def normalize_vectors(self):
80 Trims the vector lengths as to be equal in a plot.
82 for index in range(0,len(self.vectors)):
83 vectors_to_plot=self.vectors[index]
84 lengths=[len(vector) for vector in vectors_to_plot]
85 if min(lengths) != max(lengths):
86 for indexplot in range(0,len(vectors_to_plot)):
87 self.vectors[index][indexplot] = self.vectors[index][indexplot][0:min(lengths)]