(libhookecurve.py, hooke.py , fit.py, generalvclamp.py) Added color attribute to...
authordevicerandom <devnull@localhost>
Tue, 3 Mar 2009 15:14:03 +0000 (15:14 +0000)
committerdevicerandom <devnull@localhost>
Tue, 3 Mar 2009 15:14:03 +0000 (15:14 +0000)
autopeak.py
fit.py
generalvclamp.py
hooke.py
libhookecurve.py
pcluster.py

index 4e97696d40e06141d6262e6c6d8bfaf6a3c33d6b..8638cc2273b0f5a0f2d2169cdefe3e35a4d68546 100644 (file)
@@ -263,6 +263,7 @@ class autopeakCommands:
                         fitplot.styles=[]
                     else:
                         fitplot.styles.append(None)
+                        fitplot.colors.append(None)
                 else:
                     pass
  
diff --git a/fit.py b/fit.py
index 096f923e6c1f05d02215a192a9f75a7b5f0786a1..10d0331333aebf8ab2856f8d4462adf86b0b993d 100755 (executable)
--- a/fit.py
+++ b/fit.py
@@ -277,11 +277,17 @@ class fitCommands:
         fitplot.add_set(xfit,yfit)
         fitplot.add_set(clickvector_x,clickvector_y)
         
+        #FIXME: this colour/styles stuff must be solved at the root!
         if fitplot.styles==[]:
             fitplot.styles=[None,None,None,'scatter']
         else:
             fitplot.styles+=[None,'scatter']
         
+        if fitplot.colors==[]:
+            fitplot.colors=[None,None,None,None]
+        else:
+            fitplot.colors+=[None,None]
+        
         self._send_plot([fitplot])
                 
     def find_contact_point(self,plot=False):
index f4351d0b504b31c7ce991ca93154d2557c730a14..e200a59910bcd3bb643667073931fbb6941cbb9d 100644 (file)
@@ -257,10 +257,16 @@ class generalvclampCommands:
         lineplot.add_set(xtoplot,ytoplot)
         lineplot.add_set(clickvector_x, clickvector_y)
                 
+        
         if lineplot.styles==[]:
             lineplot.styles=[None,None,None,'scatter']
         else:
             lineplot.styles+=[None,'scatter']
+        if lineplot.colors==[]:
+            lineplot.styles=[None,None,None,None]
+        else:
+            lineplot.colors+=[None,None]
+        
         
         self._send_plot([lineplot])
 
index 13f79d4fe7a919fe9fb6b7411218903b0b319758..43110701da2eeeea56643eafcddf161f01d96f53 100755 (executable)
--- a/hooke.py
+++ b/hooke.py
@@ -456,6 +456,8 @@ class MainWindow(wx.Frame):
             for plot in self.plots:
                 if self.plots[c].styles==[]:
                     self.plots[c].styles=[None for item in plot.vectors] 
+                if self.plots[c].colors==[]:
+                    self.plots[c].colors=[None for item in plot.vectors] 
             
             for plot in self.plots:
                 '''
@@ -474,6 +476,27 @@ class MainWindow(wx.Frame):
                 self.current_plot_dest=dest #let's try this way to take into account the destination plot...
                 
                 c=0
+                            
+                if len(plot.colors)==0:
+                    plot.colors=[None] * len(plot.vectors)
+                if len(plot.styles)==0:
+                    plot.styles=[None] * len(plot.vectors)     
+                
+                for vectors_to_plot in self.current_vectors: 
+                    if plot.styles[c]=='scatter':
+                        if plot.colors[c]==None:
+                            self.axes[dest].scatter(vectors_to_plot[0], vectors_to_plot[1])
+                        else:
+                            self.axes[dest].scatter(vectors_to_plot[0], vectors_to_plot[1],color=plot.colors[c])
+                    else:
+                        if plot.colors[c]==None:
+                            self.axes[dest].plot(vectors_to_plot[0], vectors_to_plot[1])
+                        else:
+                            self.axes[dest].plot(vectors_to_plot[0], vectors_to_plot[1], color=plot.colors[c])
+                    self.axes[dest].hold(True)
+                    c+=1
+                    
+                '''
                 for vectors_to_plot in self.current_vectors:
                     if len(vectors_to_plot)==2: #3d plots are to come...
                         if len(plot.styles) > 0 and plot.styles[c] == 'scatter':
@@ -487,7 +510,7 @@ class MainWindow(wx.Frame):
                         c+=1
                     else:
                         pass
-               
+                '''               
                 #FIXME: tackles only 2d plots
                 self.axes[dest].set_xlabel(plot.units[0])
                 self.axes[dest].set_ylabel(plot.units[1])
@@ -606,12 +629,13 @@ class MainWindow(wx.Frame):
             dest=event.dest
             filename=event.name
             self.figures[dest].savefig(filename)
-                
+               
+        '''
         def _find_nearest_point(self, mypoint, dataset=1):
-            '''
-            Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
-            corresponds to the clicked point.
-            '''
+            
+            #Given a clicked point on the plot, finds the nearest point in the dataset (in X) that
+            #corresponds to the clicked point.
+            
             dest=self.current_plot_dest
             
             xvector=plot.vectors[dataset][0]
@@ -630,7 +654,7 @@ class MainWindow(wx.Frame):
                 index+=1
             
             return best_index,xvector[best_index],yvector[best_index]
-              
+         '''   
         
         def _plot_of_dest(self,dest=None):
             '''
@@ -663,14 +687,30 @@ class MainWindow(wx.Frame):
             #find the current plot matching the clicked destination
             plot=self._plot_of_dest()
             #plot all superimposed plots 
-            c=0      
+            c=0 
+            if len(plot.colors)==0:
+                    plot.colors=[None] * len(plot.vectors)
+            if len(plot.styles)==0:
+                    plot.styles=[None] * len(plot.vectors)     
             for plotset in plot.vectors: 
+                if plot.styles[c]=='scatter':
+                    if plot.colors[c]==None:
+                        self.axes[dest].scatter(plotset[0], plotset[1])
+                    else:
+                        self.axes[dest].scatter(plotset[0], plotset[1],color=plot.colors[c])
+                else:
+                    if plot.colors[c]==None:
+                        self.axes[dest].plot(plotset[0], plotset[1])
+                    else:
+                        self.axes[dest].plot(plotset[0], plotset[1], color=plot.colors[c])
+                '''    
                 if len(plot.styles) > 0 and plot.styles[c]=='scatter':
-                    self.axes[dest].scatter(plotset[0], plotset[1])
+                    self.axes[dest].scatter(plotset[0], plotset[1],color=plot.colors[c])
                 elif len(plot.styles) > 0 and plot.styles[c] == 'scatter_red':
                     self.axes[dest].scatter(plotset[0],plotset[1],color='red')
                 else:
                     self.axes[dest].plot(plotset[0], plotset[1])
+                '''
                 c+=1
             #plot points we have clicked
             for item in self.clicked_points:
index 7683cf1c957f2733d0b6781e5814fd8f07bfd760..11417834d196e62bb4ad753a4ed20e851372885e 100755 (executable)
@@ -107,6 +107,11 @@ class PlotObject:
         '''
         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.
index 6ce3dafd0a42f252d35a9231b1daec808733aee8..8f144fcd787c5d31fccc05e52f5f6d0e21104896 100644 (file)
@@ -365,7 +365,8 @@ class pclusterCommands:
         clustplot.add_set(Xsyn,Ysyn)
         clustplot.add_set(Xgb1,Ygb1)
         clustplot.normalize_vectors()
-        clustplot.styles=['scatter', 'scatter_red']
+        clustplot.styles=['scatter', 'scatter']
+        clustplot.colors=[None,'red']
         #clustplot.styles=['scatter',None]
         clustplot.destination=1
         self._send_plot([clustplot])