From: devicerandom Date: Tue, 3 Mar 2009 15:14:03 +0000 (+0000) Subject: (libhookecurve.py, hooke.py , fit.py, generalvclamp.py) Added color attribute to... X-Git-Tag: 0.9.0~37 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6b42cc26b1c8979f4ac5a6c925d6a527431c585b;p=hooke.git (libhookecurve.py, hooke.py , fit.py, generalvclamp.py) Added color attribute to the PlotObject --- diff --git a/autopeak.py b/autopeak.py index 4e97696..8638cc2 100644 --- a/autopeak.py +++ b/autopeak.py @@ -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 096f923..10d0331 100755 --- 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): diff --git a/generalvclamp.py b/generalvclamp.py index f4351d0..e200a59 100644 --- a/generalvclamp.py +++ b/generalvclamp.py @@ -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]) diff --git a/hooke.py b/hooke.py index 13f79d4..4311070 100755 --- 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: diff --git a/libhookecurve.py b/libhookecurve.py index 7683cf1..1141783 100755 --- a/libhookecurve.py +++ b/libhookecurve.py @@ -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. diff --git a/pcluster.py b/pcluster.py index 6ce3daf..8f144fc 100644 --- a/pcluster.py +++ b/pcluster.py @@ -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])