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