Index: guitools/PlotPanel.py
===================================================================
--- guitools/PlotPanel.py	(revision b6972a0ff9c77ad6772251f467178f745e5dc095)
+++ guitools/PlotPanel.py	(revision 052a66bcbb3220025ecb5afe3a9b2afadcc6f3c2)
@@ -34,4 +34,5 @@
         @param unit: the unit of the data
     """ 
+    return unit
     toks=re.match("^", unit)
     if not toks==None:
@@ -136,9 +137,9 @@
         #User scale
         self.xLabel ="x"
-        self.yLabel ="log10(y)"
+        self.yLabel ="y"
         self.viewModel ="--"
         # keep track if the previous transformation of x and y in Property dialog
-        self.prevXtrans =" "
-        self.prevYtrans =" "
+        self.prevXtrans ="x"
+        self.prevYtrans ="y"
         self.canvas.mpl_connect('scroll_event',self.onWheel)
         self.axes = [self.subplot]
@@ -157,4 +158,5 @@
         self.ErrBvalue=None
         self.Chivalue=None
+        
     def resetFitView(self):
         """
@@ -248,4 +250,17 @@
             dlg.ShowModal() 
 
+    def linear_plottable_fit(self, plot): 
+        """
+            when clicking on linear Fit on context menu , display Fitting Dialog
+        """
+        from fitDialog import LinearFit
+        
+        dlg = LinearFit( None, plot, self.onFitDisplay,self.returnTrans, -1, 'Linear Fit')
+       
+        if (self.xmin !=0.0 )and ( self.xmax !=0.0)\
+            and(self.xminView !=0.0 )and ( self.xmaxView !=0.0):
+            dlg.setFitRange(self.xminView,self.xmaxView,self.xmin,self.xmax)
+        dlg.ShowModal() 
+
     def _onProperties(self, event):
         """
@@ -356,22 +371,27 @@
         """
         # Slicer plot popup menu
+        id = wx.NewId()
         slicerpop = wx.Menu()
-        slicerpop.Append(313,'&Save image', 'Save image as PNG')
-        wx.EVT_MENU(self, 313, self.onSaveImage)
-        
-        slicerpop.Append(316, '&Load 1D data file')
-        wx.EVT_MENU(self, 316, self._onLoad1DData)
+        slicerpop.Append(id,'&Save image', 'Save image as PNG')
+        wx.EVT_MENU(self, id, self.onSaveImage)
+        
+        id = wx.NewId()
+        slicerpop.Append(id, '&Load 1D data file')
+        wx.EVT_MENU(self, id, self._onLoad1DData)
        
+        id = wx.NewId()
         slicerpop.AppendSeparator()
-        slicerpop.Append(315, '&Properties')
-        wx.EVT_MENU(self, 315, self._onProperties)
-        
+        slicerpop.Append(id, '&Properties')
+        wx.EVT_MENU(self, id, self._onProperties)
+        
+        id = wx.NewId()
         slicerpop.AppendSeparator()
-        slicerpop.Append(317, '&Linear Fit')
-        wx.EVT_MENU(self, 317, self.onFitting)
-        
+        slicerpop.Append(id, '&Linear Fit')
+        wx.EVT_MENU(self, id, self.onFitting)
+        
+        id = wx.NewId()
         slicerpop.AppendSeparator()
-        slicerpop.Append(318, '&Reset Graph')
-        wx.EVT_MENU(self, 318, self.onResetGraph)
+        slicerpop.Append(id, '&Reset Graph')
+        wx.EVT_MENU(self, id, self.onResetGraph)
        
         pos = event.GetPosition()
@@ -452,4 +472,5 @@
         self.subplot.set_yscale('linear')
         self.subplot.set_xscale('linear')
+        
         # Convert tuple (lo,hi) to array [(x-lo),(hi-x)]
         if dx != None and type(dx) == type(()):
@@ -462,6 +483,8 @@
                                    marker=self._symbol(symbol),linestyle='',label=label)
         else:
+            col = self._color(color)
             self.subplot.errorbar(x, y, yerr=dy, xerr=None,
-             ecolor=self._color(color), capsize=2,linestyle='', barsabove=False,
+             ecolor=col, capsize=2,linestyle='', barsabove=False,
+             mec=col, mfc=col,
              marker=self._symbol(symbol),
              lolims=False, uplims=False,
@@ -490,5 +513,19 @@
         return self.symbollist[s%len(self.symbollist)]
    
-    def _onEVT_FUNC_PROPERTY(self):
+    def _replot(self):
+        """
+            Rescale the plottables according to the latest
+            user selection and update the plot
+        """
+        self.graph.reset_scale()
+        self._onEVT_FUNC_PROPERTY(remove_fit=False)
+        
+        #TODO: Why do we have to have the following line?
+        self.fit_result.reset_view()
+        
+        self.graph.render(self)
+        self.subplot.figure.canvas.draw_idle()
+   
+    def _onEVT_FUNC_PROPERTY(self, remove_fit=True):
         """
              Receive the x and y transformation from myDialog,Transforms x and y in View
@@ -497,8 +534,11 @@
         list =[]
         list = self.graph.returnPlottable()
-        self.fit_result.x =[]  
-        self.fit_result.y =[] 
-        self.fit_result.dx=None
-        self.fit_result.dy=None
+        
+        if remove_fit:
+            self.fit_result.x =[]  
+            self.fit_result.y =[] 
+            self.fit_result.dx=None
+            self.fit_result.dy=None
+            self.graph.delete(self.fit_result)
         
         for item in list:
Index: guitools/fitDialog.py
===================================================================
--- guitools/fitDialog.py	(revision 6a8adb0f76e1dc1dc3d0f6e360e39980ea9dcf65)
+++ guitools/fitDialog.py	(revision 052a66bcbb3220025ecb5afe3a9b2afadcc6f3c2)
@@ -13,4 +13,10 @@
         Return a float in a standardized, human-readable formatted string 
     """
+    try: 
+        value = float(value)
+    except:
+        print "returning 0"
+        return "0"
+    
     if high:
         return "%-6.4g" % value
@@ -130,5 +136,5 @@
         iy += 1
         ix = 0
-        sizer.Add(wx.StaticText(self, -1, 'Plotted range'),(iy, ix),(1,1),\
+        sizer.Add(wx.StaticText(self, -1, 'Maximum range'),(iy, ix),(1,1),\
                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         ix +=1
@@ -190,23 +196,23 @@
         
         if self.Avalue==None:
-            self.tcA.SetLabel(str(self.default_A))
+            self.tcA.SetLabel(format_number(self.default_A))
         else :
-            self.tcA.SetLabel(str(self.Avalue))
+            self.tcA.SetLabel(format_number(self.Avalue))
         if self.Bvalue==None:
-            self.tcB.SetLabel(str(self.default_B))
+            self.tcB.SetLabel(format_number(self.default_B))
         else:
-            self.tcB.SetLabel(str(self.Bvalue))
+            self.tcB.SetLabel(format_number(self.Bvalue))
         if self.ErrAvalue==None:
-            self.tcErrA.SetLabel(str(0.0))
+            self.tcErrA.SetLabel(format_number(0.0))
         else:
-            self.tcErrA.SetLabel(str(self.ErrAvalue))
+            self.tcErrA.SetLabel(format_number(self.ErrAvalue))
         if self.ErrBvalue==None:
-            self.tcErrB.SetLabel(str(0.0))
+            self.tcErrB.SetLabel(format_number(0.0))
         else:
-            self.tcErrB.SetLabel(str(self.ErrBvalue))
+            self.tcErrB.SetLabel(format_number(self.ErrBvalue))
         if self.Chivalue==None:
-            self.tcChi.SetLabel(str(0.0))
+            self.tcChi.SetLabel(format_number(0.0))
         else:
-            self.tcChi.SetLabel(str(self.Chivalue))
+            self.tcChi.SetLabel(format_number(self.Chivalue))
         if self.plottable.x !=[]:
             self.mini =min(self.plottable.x)
Index: guitools/plottables.py
===================================================================
--- guitools/plottables.py	(revision 05da1f8994b512c6a943f61974e1f83b0508cfab)
+++ guitools/plottables.py	(revision 052a66bcbb3220025ecb5afe3a9b2afadcc6f3c2)
@@ -173,4 +173,24 @@
         """Detect if any graphed plottables have changed"""
         return any([p.changed() for p in self.plottables])
+    
+    def get_range(self):
+        """
+            Return the range of all displayed plottables
+        """
+        min = None
+        max = None
+        
+        for p in self.plottables:
+            if p.hidden==True:
+                continue
+            
+            if not p.x==None:
+                for x_i in p.x:
+                    if min==None or x_i<min:
+                        min = x_i
+                    if max==None or x_i>max:
+                        max = x_i
+                        
+        return min, max
 
     def delete(self,plottable):
@@ -183,4 +203,10 @@
             self.color =0 
             
+    def reset_scale(self):
+        """
+            Resets the scale transformation data to the underlying data
+        """
+        for p in self.plottables:
+            p.reset_view()
 
     def reset(self):
@@ -321,5 +347,36 @@
 
 
-class Plottable:
+class Plottable(object):
+    
+    # Short ascii name to refer to the plottable in a menu 
+    short_name = None
+    
+    # Data
+    x  = None
+    y  = None
+    dx = None
+    dy = None
+    
+    # Parameter to allow a plot to be part of the list without being displayed
+    hidden = False
+
+    def __setattr__(self, name, value):
+        """
+            Take care of changes in View when data is changed.
+            This method is provided for backward compatibility.
+        """
+        object.__setattr__(self, name, value)
+        
+        if name in ['x', 'y', 'dx', 'dy']:
+            self.reset_view()
+            #print "self.%s has been called" % name
+
+    def set_data(self, x, y, dx=None, dy=None):
+        self.x = x
+        self.y = y
+        self.dy = dy
+        self.dx = dx
+        self.transformView()
+    
     def xaxis(self, name, units):
         """
@@ -409,4 +466,14 @@
         plot.xaxis(self._xaxis, self._xunit)
         plot.yaxis(self._yaxis, self._yunit)
+        
+    def is_empty(self):
+        """
+            Returns True if there is no data stored in the plottable
+        """
+        if not self.x==None and len(self.x)==0 \
+            and not self.y==None and len(self.y)==0:
+            return True
+        return False
+        
         
     def colors(self):
@@ -500,4 +567,5 @@
             self.funcdx= None
             self.funcdy= None
+
         def transform(self, x=None,y=None,dx=None, dy=None):
             """
@@ -512,6 +580,9 @@
             # Sanity check
             # Do the transofrmation only when x and y are empty
+            has_err_x = not (dx==None or len(dx)==0)
+            has_err_y = not (dy==None or len(dy)==0)
+            
             if (x!=None) and (y!=None): 
-                if dx and not len(x)==len(dx):
+                if not dx==None and not len(dx)==0 and not len(x)==len(dx):
                         raise ValueError, "Plottable.View: Given x and dx are not of the same length" 
                 # Check length of y array
@@ -519,15 +590,25 @@
                     raise ValueError, "Plottable.View: Given y and x are not of the same length"
             
-                if dy and not len(y)==len(dy):
-                    raise ValueError, "Plottable.View: Given y and dy are not of the same length"
+                if not dy==None and not len(dy)==0 and not len(y)==len(dy):
+                    message = "Plottable.View: Given y and dy are not of the same length: len(y)=%s, len(dy)=%s" %(len(y), len(dy))
+                    raise ValueError, message
+                
+                
                 self.x = []
                 self.y = []
-                self.dx = []
-                self.dy = []
+                if has_err_x:
+                    self.dx = []
+                else:
+                    self.dx = None
+                if has_err_y:
+                    self.dy = []
+                else:
+                    self.dy = None
                 tempx=[]
                 tempy=[]
-                if dx==None:
+                
+                if not has_err_x:
                     dx=numpy.zeros(len(x))
-                if dy==None:
+                if not has_err_y:
                     dy=numpy.zeros(len(y))
               
@@ -536,24 +617,30 @@
                          tempx =self.funcx(x[i],y[i])
                          tempy =self.funcy(y[i],x[i])
-                         tempdx = self.funcdx(x[i], y[i], dx[i], dy[i])
-                         tempdy = self.funcdy(y[i], x[i], dy[i], dx[i])
+                         if has_err_x:
+                             tempdx = self.funcdx(x[i], y[i], dx[i], dy[i])
+                         if has_err_y:
+                             tempdy = self.funcdy(y[i], x[i], dy[i], dx[i])
                         
                          self.x.append(tempx)
                          self.y.append(tempy)
-                         self.dx.append(tempdx)
-                         self.dy.append(tempdy)
+                         if has_err_x:
+                             self.dx.append(tempdx)
+                         if has_err_y:
+                             self.dy.append(tempdy)
                     except:
                          tempx=x[i]
                          tempy=y[i]
-                         print "View.transform: skipping point x %g" % x[i]
-                         print "View.transform: skipping point y %g" % y[i]
-                         print "View.transform: skipping point dy %g" % dy[i]
+                         print "View.transform: skipping point x=%g y=%g" % (x[i], y[i])
                          
                          print sys.exc_value  
                
                 # Sanity check
-                if not (len(self.x)==len(self.dx))and(len(self.x)==len(self.dy))\
-                and(len(self.x)==len(self.y))and(len(self.y)==len(self.dy)) :
-                        raise ValueError, "Plottable.View: Given x,y,dy and dx are not of the same length" 
+                if not len(self.x)==len(self.y):
+                    raise ValueError, "Plottable.View: transformed x and y are not of the same length" 
+                if has_err_x and not (len(self.x) and len(self.dx)):
+                    raise ValueError, "Plottable.View: transformed x and dx are not of the same length" 
+                if has_err_y and not (len(self.y) and len(self.dy)):
+                    raise ValueError, "Plottable.View: transformed y and dy are not of the same length" 
+                
                 # Check that negative values are not plot on x and y axis for log10 transformation
                 self.check_data_logX()
@@ -564,5 +651,4 @@
                 self.DXreel = self.dx
                 self.DYreel = self.dy
-                
                 
                 
@@ -749,5 +835,4 @@
         
     def render(self,plot,**kw):
-        #plot.curve(self.x,self.y,dy=self.dy,**kw)
         plot.curve(self.view.x,self.view.y,dy=self.view.dy,**kw)
 
