-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
-#
-# This file is part of Hooke.
-#
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
-#
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke. If not, see
-# <http://www.gnu.org/licenses/>.
-
-class PlotObject(object):
-
- def __init__(self):
-
- '''
- the plot destination
- 0=top
- 1=bottom
- '''
- self.destination=0
-
- '''
- self.vectors is a multidimensional array:
- self.vectors[0]=plot1
- self.vectors[1]=plot2
- self.vectors[2]=plot3
- etc.
-
- 2 curves in a x,y plot are:
- [[[x1],[y1]],[[x2],[y2]]]
- for example:
- x1 y1 x2 y2
- [[[1,2,3,4],[10,20,30,40]],[[3,6,9,12],[30,60,90,120]]]
- x1 = self.vectors[0][0]
- y1 = self.vectors[0][1]
- x2 = self.vectors[1][0]
- y2 = self.vectors[1][1]
- '''
- self.vectors=[]
-
- '''
- self.units is simpler. for each plot with N axes (x,y,z...) only N labels
- can be made, regardless of the number of superimposed plots
- so units for the double plot above is: [unitx, unity]
-
- units are strings
- '''
- self.units=['', '']
-
- '''
- xaxes and yaxes directions. 0, 0 means the common +X=right, +Y=top directions
- '''
- self.xaxes = 0
- self.yaxes = 0
-
- self.filename = ''
- self.title = '' #title
-
- '''
- styles: defines what is the style of the current plots. If undefined or None, it is line plot.
- If an element of the list is 'scatter', the corresponding dataset
- is drawn with scattered points and not a continuous line.
- '''
- self.styles = []
-
- '''
- colors: define what is the colour of the current plots
- '''
- self.colors = []
-
- def add_set(self, x, y):
- '''
- Adds an x, y data set to the vectors.
- '''
- self.vectors.append([])
- self.vectors[-1].append(x)
- self.vectors[-1].append(y)
-
- def remove_set(self, whichset):
- '''
- Removes a set
- '''
- #TODO: do we need 'waste' here?
- waste = self.vectors.pop(whichset)
-
- def normalize_vectors(self):
- '''
- Trims the vector lengths as to be equal in a plot.
- '''
- for index in range(0,len(self.vectors)):
- vectors_to_plot=self.vectors[index]
- lengths=[len(vector) for vector in vectors_to_plot]
- if min(lengths) != max(lengths):
- for indexplot in range(0,len(vectors_to_plot)):
- self.vectors[index][indexplot] = self.vectors[index][indexplot][0:min(lengths)]
-
+#!/usr/bin/env python\r
+\r
+'''\r
+plot.py\r
+\r
+Plot class for Hooke.\r
+\r
+Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)\r
+\r
+This program is released under the GNU General Public License version 2.\r
+'''\r
+\r
+class Invert(object):\r
+\r
+ def __init__(self):\r
+ self.x = False\r
+ self.y = False\r
+\r
+\r
+class Plot(object):\r
+\r
+ def __init__(self):\r
+ self.corrected_curves = []\r
+ self.curves = []\r
+ self.invert = Invert()\r
+ self.raw_curves = []\r
+ self.results = {}\r
+ self.title = ''\r
+\r
+ def normalize(self):\r
+ '''\r
+ Trims the vector lengths as to be equal in a plot.\r
+ '''\r
+ lengths = []\r
+ for curve in self.curves:\r
+ lengths.append(len(curve.x))\r
+ lengths.append(len(curve.y))\r
+ if min(lengths) != max(lengths):\r
+ curve.x = curve.x[0:min(lengths)]\r
+ curve.y = curve.y[0:min(lengths)]\r