Index: guitools/PlotPanel.py
===================================================================
--- guitools/PlotPanel.py	(revision d490a0238cd7d8ecc685f42708ec101f1543c5ba)
+++ guitools/PlotPanel.py	(revision f52bea1de61984ae151243e2fed0972a4c7d83d5)
@@ -58,9 +58,11 @@
         self.symbollist = ['o','x','^','v','<','>','+','s','d','D','h','H','p']
         #User scale
-        self.xscales =""
-        self.yscales =""
+        self.xscales ="x"
+        self.yscales ="Log(y)"
         # keep track if the previous transformation of x and y in Property dialog
         self.prevXtrans =" "
         self.prevYtrans =" "
+    def returnTrans(self):
+        return self.xscales,self.yscales
         
     def setTrans(self,xtrans,ytrans): 
@@ -83,5 +85,5 @@
             first_item = list.keys()[0]
             #print first_item, list[first_item].__class__.__name__
-            dlg = LinearFit( None, first_item, self.onFitDisplay, -1, 'Fitting')
+            dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, 'Fitting')
             dlg.ShowModal() 
 
@@ -125,5 +127,30 @@
          else:
              return math.sqrt(x)
-         
+    def toLogX(self,x):
+        """
+            This function is used to load value on Plottable.View
+            calculate log x
+            @param x: float value
+        """
+        if not x > 0:
+            raise ValueError, "Log(X)of a negative value "
+        else:
+            return math.log(x)
+        
+    def toOneOverX(self,x):
+        if x !=0:
+            return 1/x
+        else:
+            raise ValueError,"cannot divide by zero"
+    def toOneOverSqrtX(self,x):
+        if x > 0:
+            return 1/math.sqrt(x)
+        else:
+            raise ValueError,"cannot be computed"
+    def toLogYX2(self):
+        if y*(x**2) >0:
+            return math.log(y*(x**2))
+        else:
+             raise ValueError,"cannot be computed"
     def toLogXY(self,x,y):
         """
@@ -371,32 +398,38 @@
         for item in list:
             if ( self.xscales=="x" ):
-                item.transform_x(  self.toX, self.errFunctoX )
+                item.transform_x(  self.toX, self.errToX )
                 self.set_xscale("linear")
-                self.graph.xaxis('\\rm{q} ', 'A^{-1}')
+                name, units = item.get_xaxis()
+                self.graph.xaxis("%s" % name,  "%s^{-1}" % units)
                 
             if ( self.xscales=="x^(2)" ):
-                item.transform_x(  self.toX2, self.errFuncToX2 )
+                item.transform_x(  self.toX2, self.errToX2 )
                 self.set_xscale('linear')
-                self.graph.xaxis('\\rm{q^{2}} ', 'A^{-2}')
+                name, units = item.get_xaxis()
+                self.graph.xaxis("%s^{2}" % name,  "%s^{-2}" % units)
                 
             if (self.xscales=="Log(x)" ):
-                item.transform_x(  self.toX, self.errFuncToLogX )
+                item.transform_x(  self.toX, self.errToLogX )
                 self.set_xscale("log")
-                self.graph.xaxis('\\rm{q} ', 'A^{-1}')
+                name, units = item.get_xaxis()
+                self.graph.xaxis("%s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="y" ):
-                item.transform_y(  self.toX, self.errFunctoX )
+                item.transform_y(  self.toX, self.errToX )
                 self.set_yscale("linear")
-                self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
+                name, units = item.get_yaxis()
+                self.graph.yaxis("%s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="Log(y)" ): 
-                item.transform_y(  self.toX, self.errFuncToLogX)
+                item.transform_y(  self.toX, self.errToLogX)
                 self.set_yscale("log")  
-                self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
+                name, units = item.get_yaxis()
+                self.graph.yaxis("%s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="y^(2)" ):
-                item.transform_y(  self.toX2, self.errFuncToX2 )    
+                item.transform_y(  self.toX2, self.errToX2 )    
                 self.set_yscale("linear")
-                self.graph.yaxis("\\rm{Intensity^{2}} ","cm^{-2}")
+                name, units = item.get_yaxis()
+                self.graph.yaxis("%s^2" % name,  "%s^{-2}" % units)
    
         self.prevXtrans = self.xscales 
@@ -405,5 +438,6 @@
         self.graph.render(self)
         self.subplot.figure.canvas.draw_idle()
-    def errFunctoX(self,x,dx=None):
+        
+    def errToX(self,x,dx=None):
         """
             calculate error of x**2
@@ -411,10 +445,11 @@
             @param dx: float value
         """
-        if math.fabs(dx) >= math.fabs(x):
+        if (dx != None) and (math.fabs(dx) >= math.fabs(x)):
             return math.fabs(0.9*x)
         if dx==None:
              return 0
         return math.fabs(dx)
-    def errFuncToX2(self,x,dx=None):
+    
+    def errToX2(self,x,dx=None):
         """
             calculate error of x**2
@@ -429,5 +464,5 @@
         else:
             return 0.0
-    def errFuncfromX2(self,x,dx=None):
+    def errFromX2(self,x,dx=None):
         """
             calculate error of sqrt(x)
@@ -447,5 +482,5 @@
             return math.fabs(err)
         
-    def errFuncToLogX(self,x,dx=None):
+    def errToLogX(self,x,dx=None):
         """
             calculate error of Log(xy)
@@ -466,13 +501,21 @@
         return math.fabs(err)
         
-    def errFuncfromLogXY(self,x,dx=None):
+    def errToLogXY(self,x,y,dx=None, dy=None):
         """
             calculate error of Log(xy)
-            @param x: float value
-            @param dx: float value
-        """
-        return 
-       
-                   
+        """
+        if dx==None:
+            err = x*(dy**2)/y
+        elif dy==None:
+            err = y*(dx**2)/x
+        elif (x!=0) and (y!=0):
+            err = y*(dx**2)/x + x*(dy**2)/y
+        if err >= 0:
+            if  math.sqrt(err)> x:
+                err= 0.9*x
+            return math.sqrt(err)
+        else:
+            raise ValueError, "cannot compute this error"
+                      
     def onFitDisplay(self, plottable):
         """
@@ -484,4 +527,5 @@
         self.graph.add(plottable)
         self.graph.render(self)
+        self.graph.delete(plottable)
         self.subplot.figure.canvas.draw_idle()
         
Index: guitools/fitDialog.py
===================================================================
--- guitools/fitDialog.py	(revision 57896544f08828746f936a04451449e4a91450e1)
+++ guitools/fitDialog.py	(revision f52bea1de61984ae151243e2fed0972a4c7d83d5)
@@ -9,5 +9,5 @@
 class LinearFit(wx.Dialog):
     #def __init__(self, parent, id, title):
-    def __init__(self, parent, plottable, push_data, id, title):
+    def __init__(self, parent, plottable, push_data,transform, id, title):
         wx.Dialog.__init__(self, parent, id, title, size=(550, 300))
         """
@@ -15,8 +15,10 @@
         """
         self.parent = parent
+        self.transform = transform
         #dialog panel self call function to plot the fitting function
         self.push_data = push_data
         #dialog self plottable
         self.plottable = plottable
+        
         
         #Dialog interface
@@ -75,8 +77,9 @@
         sizer.Add(self.tcXmax, (iy, ix))
         iy += 1
-        ix = 1
+        ix = 3
         sizer.Add(self.btFit, (iy, ix))
         self.btFit.Bind(wx.EVT_BUTTON, self._onFit)
-        ix += 2
+        iy +=1
+        ix = 3
         sizer.Add(btClose, (iy, ix))
        
@@ -92,7 +95,13 @@
         
     def _onFit(self ,event):
-       
-        print "we are on fit"
+        """
+            Performs the fit. Receive an event when clicking on the button Fit.Computes chisqr ,
+            A and B parameters of the best linear fit y=Ax +B
+            Push a plottable to 
+        """
+       
         temp =[]
+        tempx=[]
+        tempy=[]
         xmin = self._checkVal(self.tcXmin.GetValue())
         xmax = self._checkVal(self.tcXmax.GetValue())
@@ -100,73 +109,78 @@
         #store the values of View in x,y, dx,dy
         x,y,dx,dy=self.plottable.returnValuesOfView()
-       
+        self.xtrans,self.ytrans= self.transform()
+        #Display the fittings values
+        default_A = self.model.getParam('A') 
+        default_B = self.model.getParam('B') 
+        cstA = fittings.Parameter(self.model, 'A', default_A)
+        cstB  = fittings.Parameter(self.model, 'B', default_B)
+        if  self.ytrans == "Log(y)":
+            for y_i in y:
+                tempy.append(log(y_i))       
+            chisqr, out, cov = fittings.sansfit(self.model, 
+                            [cstA, cstB],x, tempy,dy,min(x),max(x))
+        else :
+            chisqr, out, cov = fittings.sansfit(self.model, 
+                            [cstA, cstB],x, y,dy,min(x),max(x))
+        #Check that cov and out are iterable before displaying them
+        if cov ==None:
+            errA =0.0
+            errB =0.0
+        else:
+            errA= math.sqrt(cov[0][0])
+            errB= math.sqrt(cov[1][1])
+        if out==None:
+            cstA=0.0
+            cstB=0.0
+        else:
+            cstA=out[0]
+            cstB=out[1]
+        self.model.setParam('A', float(cstA))
+        self.model.setParam('B', float(cstB))
+        
         if x != []:
             if xmin !=None  and xmax != None:
                 for j in range(len(x)):
-                    if x[j]>xmin and x[j]<xmax:
+                    if x[j] > xmin and x[j] < xmax:
                         temp.append(self.model.run(x[j]))
-                    
-                        for y_i in temp:
-                            tempdy.append(math.sqrt(y_i)) 
             else:
                 # x has a default value in case the user doesn't load data
                 for x_i in x:
                     temp.append(self.model.run(x_i))
-        
-                    self.tcXmin.SetValue(str(min(x)))
-                    self.tcXmax.SetValue(str(max(x)))
-                    xmin = self._checkVal(self.tcXmin.GetValue())
-                    xmax = self._checkVal(self.tcXmax.GetValue())
+                self.tcXmin.SetValue(str(min(x)))
+                self.tcXmax.SetValue(str(max(x)))
+                xmin = self._checkVal(self.tcXmin.GetValue())
+                xmax = self._checkVal(self.tcXmax.GetValue())
                 
             self.file_data1.x =x
-            self.file_data1.y =temp
-          
+            # Create new data plottable with result
+            self.file_data1.y =[]
+            self.xtrans, self.ytrans= self.transform()
+            
+            if self.ytrans == "Log(y)":
+                for x_i in x:
+                    self.file_data1.y.append(exp(self.model.run(x_i)))
+            else:
+                self.file_data1.y =temp     
             self.file_data1.dx=None
             self.file_data1.dy=None
+            
             self.file_data1.reset_view()
-        
-            # Display the fittings values
-            default_A = self.model.getParam('A') 
-            default_B = self.model.getParam('B') 
-            cstA = fittings.Parameter(self.model, 'A', default_A)
-            cstB  = fittings.Parameter(self.model, 'B', default_B)        
-            chisqr, out, cov = fittings.sansfit(self.model, 
-               [cstA, cstB],x, y,dy,min(x),max(x))
             
-           
-            #Check that cov and out are iterable before displaying them
-            if cov ==None:
-                errA =str(0.0)
-                errB =str(0.0)
-            else:
-                errA= str(math.sqrt(cov[0][0]))
-                errB= str(math.sqrt(cov[1][1]))
-            if out==None:
-                cstA=str(0.0)
-                cstB=str(0.0)
-            else:
-                cstA=str(out[0])
-                cstB=str(out[1])
-           
-            self.model.setParam('A', float(cstA))
-            self.model.setParam('B', float(cstB))
-             # Create new data plottable with result
-            self.file_data1.y = []
-           
-            for x_i in x:
-                self.file_data1.y.append(self.model.run(x_i))
             #Send the data to display to the PlotPanel
-            self.file_data1.reset_view()
+            #
             self.push_data(self.file_data1)
             # Display the fitting value on the Fit Dialog
-            self._onsetValues(cstA, cstB, errA,errB,str(chisqr))
+            self._onsetValues(cstA, cstB, errA,errB,chisqr)
        
     def _onsetValues(self,cstA,cstB,errA,errB,Chi):
-        
-         self.tcA.SetValue(cstA)
-         self.tcB.SetValue(cstB)
-         self.tcErrA.SetValue(errA)
-         self.tcErrB.SetValue(errB)
-         self.tcChi.SetValue(Chi)
+         """
+              Display  the value on fit Dialog 
+         """
+         self.tcA.SetValue(str(cstA))
+         self.tcB.SetValue(str(cstB))
+         self.tcErrA.SetValue(str(errA))
+         self.tcErrB.SetValue(str(errB))
+         self.tcChi.SetValue(str(Chi))
          
     def _returnPlottable(self):
@@ -175,6 +189,6 @@
     def _checkVal(self,value):
         """
-                Ensure that fields parameter contains a value 
-                before sending to fit in Plotter1D
+                Ensure that field parameter contains a value 
+                before sending to fit 
         """
         try:
Index: guitools/plottables.py
===================================================================
--- guitools/plottables.py	(revision 57896544f08828746f936a04451449e4a91450e1)
+++ guitools/plottables.py	(revision f52bea1de61984ae151243e2fed0972a4c7d83d5)
@@ -392,4 +392,5 @@
         
     def returnValuesOfView(self):
+        
         return self.view.returnXview()
         
Index: guitools/requirements.txt
===================================================================
--- guitools/requirements.txt	(revision 8742751269fdb85983dfdbacf668c58dadfdc1fc)
+++ guitools/requirements.txt	(revision f52bea1de61984ae151243e2fed0972a4c7d83d5)
@@ -36,4 +36,6 @@
   	 y = A * log(x) + B, which is a straight line in the y vs log(x) representation.
   	 
+--> [ALINA] woring better...I am concerned how to fit a straight line when x is changing too?
+  	 
       
 - NOTES that might help for bugs
@@ -49,5 +51,6 @@
   
   2- There are additional y scales we need: y, y^2, log(y), 1/y, 1/sqrt(y), log(y * x), log(y * x^2)
-  3- You should change the label according to what the user chose, and not hard-code them.
+  	
+  3-[DONE] You should change the label according to what the user chose, and not hard-code them.
      For example, in PlotPanel._onEVT_FUNC_PROPERTY, replace
           
@@ -60,6 +63,8 @@
      That way it still works even if the user is not plotting Intensity versus Q.
      
-  4- In the fit dialog, put the "fit" and "Close" button in the bottom right corner, like in a standard file dialog.
+  4- [DONE] In the fit dialog, put the "fit" and "Close" button in the bottom right corner, like in a standard file dialog.
+  
   5- The layout of the Fit Dialog should be improved.
+  
   6- The code should be well documented and clean-up (no print statements).
   
