Index: guitools/PlotPanel.py
===================================================================
--- guitools/PlotPanel.py	(revision 47f695c93a98ae92c88d22237d0a4cb935c4d959)
+++ guitools/PlotPanel.py	(revision 34ae30236bd5c694f1d13da4a01dc8c70f84415e)
@@ -35,6 +35,6 @@
         # TODO: use proper scale transformers
         if scale=='log':
-            lo,hi = log10(lo),log10(hi)
-            if pt is not None: pt = log10(pt)
+            lo,hi = math.log10(lo),math.log10(hi)
+            if pt is not None: pt = math.log10(pt)
     
         # Compute delta from axis range * %, or 1-% if persent is negative
@@ -53,5 +53,6 @@
         # Convert transformed values back to the original scale
         if scale=='log':
-            lo,hi = pow(10.,lo),pow(10.,hi)
+            lo,hi = math.pow(10.,lo),math.pow(10.,hi)
+            print "check y axis rescale"
     
         return (lo,hi)
@@ -108,4 +109,5 @@
         """
         ax = event.inaxes
+        
         step = event.step
 
@@ -123,20 +125,21 @@
             xdata,ydata = None,None
             x,y = event.x,event.y
+           
             for ax in self.axes:
                 insidex,_ = ax.xaxis.contains(event)
                 if insidex:
                     xdata,_ = ax.transAxes.inverse_xy_tup((x,y))
-                    #print "xaxis",x,"->",xdata
+                    print "xaxis",x,"->",xdata
                 insidey,_ = ax.yaxis.contains(event)
                 if insidey:
                     _,ydata = ax.transAxes.inverse_xy_tup((x,y))
-                    #print "yaxis",y,"->",ydata
+                    print "yaxis",y,"->",ydata
             if xdata is not None:
                 lo,hi = ax.get_xlim()
-                lo,hi = _rescale(lo,hi,step,bal=xdata)
+                lo,hi = _rescale(lo,hi,step,bal=xdata,scale=ax.get_xscale())
                 ax.set_xlim((lo,hi))
             if ydata is not None:
                 lo,hi = ax.get_ylim()
-                lo,hi = _rescale(lo,hi,step,bal=ydata)
+                lo,hi = _rescale(lo,hi,step,bal=ydata,scale=ax.get_yscale())
                 ax.set_ylim((lo,hi))
 
@@ -173,16 +176,22 @@
             The user selects a transformation for x or y value and a new plot is displayed
         """
-        from PropertyDialog import Properties
-        dial = Properties(self, -1, 'Properties')
-        dial.setValues( self.prevXtrans, self.prevYtrans,self.viewModel )
-        if dial.ShowModal() == wx.ID_OK:
-            self.xscales, self.yscales,self.viewModel = dial.getValues()
-            if self.viewModel =="Guinier lny vs x^(2)":
-                self.xscales="x^(2)"
-                self.yscales="ln(y)"
-                self.viewModel = "--"
-                dial.setValues( self.xscales, self.yscales,self.viewModel )
-            self._onEVT_FUNC_PROPERTY()
-        dial.Destroy()
+        list =[]
+        list = self.graph.returnPlottable()
+        if len(list.keys())>0:
+            first_item = list.keys()[0]
+            if first_item.x !=[]:
+                from PropertyDialog import Properties
+                dial = Properties(self, -1, 'Properties')
+                dial.setValues( self.prevXtrans, self.prevYtrans,self.viewModel )
+                if dial.ShowModal() == wx.ID_OK:
+                    self.xscales, self.yscales,self.viewModel = dial.getValues()
+                    if self.viewModel =="Guinier lny vs x^(2)":
+                        self.xscales="x^(2)"
+                        self.yscales="ln(y)"
+                        self.viewModel = "--"
+                        dial.setValues( self.xscales, self.yscales,self.viewModel )
+                    self._onEVT_FUNC_PROPERTY()
+                dial.Destroy()
+           
   
     def set_yscale(self, scale='linear'):
@@ -284,4 +293,8 @@
         slicerpop.Append(317, '&Linear Fit')
         wx.EVT_MENU(self, 317, self.onFitting)
+        
+        slicerpop.AppendSeparator()
+        slicerpop.Append(318, '&Reset Graph')
+        wx.EVT_MENU(self, 318, self.onResetGraph)
        
         pos = event.GetPosition()
@@ -426,5 +439,5 @@
                 self.set_xscale("log")
                 name, units = item.get_xaxis() 
-                self.graph.xaxis("Log10 %s" % name,  "%s^{-1}" % units)
+                self.graph.xaxis("\log_{10}\ \  %s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="ln(y)" ):
@@ -432,5 +445,5 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("log %s" % name,  "%s^{-1}" % units)
+                self.graph.yaxis("log\ \ %s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="y" ):
@@ -444,5 +457,5 @@
                 self.set_yscale("log")  
                 name, units = item.get_yaxis()
-                self.graph.yaxis("Log10 %s" % name,  "%s^{-1}" % units)
+                self.graph.yaxis("\log_{10}\ \ %s" % name,  "%s^{-1}" % units)
                 
             if ( self.yscales=="y^(2)" ):
@@ -450,5 +463,5 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("%s^2" % name,  "%s^{-2}" % units)
+                self.graph.yaxis("%s^{2}" % name,  "%s^{-2}" % units)
                 
             if ( self.yscales =="1/y"):
@@ -456,5 +469,5 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("%s" % name,  "%s" % units)
+                self.graph.yaxis("%s" % name,  "\ \%s" % units)
                 
             if ( self.yscales =="1/sqrt(y)" ):
@@ -462,5 +475,5 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("%s" %name,  "%s" % units)
+                self.graph.yaxis("\sqrt{%s}" %name,  "%s" % units)
                 
             if ( self.yscales =="ln(y*x)"):
@@ -469,5 +482,5 @@
                 yname, yunits = item.get_yaxis()
                 xname, xunits = item.get_xaxis()
-                self.graph.yaxis("Log %s%s" % (yname,xname),  "%s^{-1}%s^{-1}" % (yunits,xunits))
+                self.graph.yaxis("log\ %s %s" % (yname,xname),  "%s^{-1}%s^{-1}" % (yunits,xunits))
                 
             if ( self.yscales =="ln(y*x^(2))"):
@@ -502,5 +515,5 @@
         self.subplot.figure.canvas.draw_idle()
         
-    def onFitDisplay(self, plottable):
+    def onFitDisplay(self, plottable,xmin,xmax):
         """
             Add a new plottable into the graph .In this case this plottable will be used 
@@ -508,6 +521,9 @@
             @param plottable: the plottable to plot
         """
+        list =[]
+        list = self.graph.returnPlottable()
+        for item in list:
+            item.onFitRange(xmin,xmax)
         #Add the data to fit 
-       
         self.graph.add(plottable)
         self.graph.render(self)
@@ -516,5 +532,11 @@
         self.graph.delete(plottable)
    
-
+    def onResetGraph(self,event):
+        list =[]
+        list = self.graph.returnPlottable()
+        for item in list:
+            item.onReset()
+        self.graph.render(self)
+        self.subplot.figure.canvas.draw_idle()
         
 class NoRepaintCanvas(FigureCanvasWxAgg):
Index: guitools/fitDialog.py
===================================================================
--- guitools/fitDialog.py	(revision f193585958b4a7d32fd27d957003d126d30798d3)
+++ guitools/fitDialog.py	(revision 34ae30236bd5c694f1d13da4a01dc8c70f84415e)
@@ -171,10 +171,10 @@
                     if (self.xtrans.lower() == "log10(x)"):
                         for i in range(len(x)):
-                            if x[i]>=xmin:
+                            if x[i]>= math.log10(xmin):
                                 tempy.append(math.log10(y[i])) 
                                 tempdy.append(transform.errToLogX(y[i],0,dy[i],0))
                     else:
-                        for y_i in y:
-                            tempy.append(math.log10(y_i)) 
+                        for i in range(len(y)):
+                            tempy.append(math.log10(y[i])) 
                             tempdy.append(transform.errToLogX(y[i],0,dy[i],0))
                 else:
@@ -184,5 +184,5 @@
                 if (self.xtrans.lower() == "log10(x)"):
                     for x_i in x:
-                        if x_i >= xmin:
+                        if x_i >= math.log10(xmin):
                             tempx.append(math.log10(x_i)) 
                 else:
@@ -196,6 +196,9 @@
                        
                 #Find the fitting parameters
-
-                chisqr, out, cov = fittings.sansfit(self.model, 
+                if (self.xtrans.lower() == "log10(x)"):
+                    chisqr, out, cov = fittings.sansfit(self.model, [self.cstA, self.cstB],
+                    tempx, tempy,tempdy,math.log10(xmin),math.log10(xmax))
+                else:
+                    chisqr, out, cov = fittings.sansfit(self.model, 
                                 [self.cstA, self.cstB],tempx, tempy,tempdy,xminView,xmaxView)
                 print "this out",out
@@ -259,5 +262,5 @@
                 
                 #Send the data to display to the PlotPanel
-                self.push_data(self.file_data1)
+                self.push_data(self.file_data1,xminView,xmaxView)
                 
                 # Display the fitting value on the Fit Dialog
@@ -310,5 +313,5 @@
         if (self.xtrans=="log10(x)" ):
             if x >0:
-                return math.log10(x)
+                return x
             else:
                 raise ValueError,"cannot compute log of a negative number"
Index: guitools/plottables.py
===================================================================
--- guitools/plottables.py	(revision 47f695c93a98ae92c88d22237d0a4cb935c4d959)
+++ guitools/plottables.py	(revision 34ae30236bd5c694f1d13da4a01dc8c70f84415e)
@@ -53,5 +53,17 @@
             if not cond: return False
         return True
-
+def error_msg(msg, parent=None):
+    """
+    Signal an error condition -- in a GUI, popup a error dialog
+    """
+    # Code brought with minor podifications from mpl.backends.backend_wx
+    # Copyright (C) Jeremy O'Donoghue & John Hunter, 2003-4
+    dialog =wx.MessageDialog(parent  = parent,
+                             message = msg,
+                             caption = 'Polplot error',
+                             style=wx.OK | wx.CENTRE)
+    dialog.ShowModal()
+    dialog.Destroy()
+    return None
 # Graph structure for holding multiple plottables
 class Graph:
@@ -383,5 +395,8 @@
         """ Reload view with new value to plot"""
         self.view = self.View(self.x, self.y, self.dx, self.dy)
-        
+        self.view.Xreel = self.view.x
+        self.view.Yreel = self.view.y
+        self.view.DXreel = self.view.dx
+        self.view.DYreel = self.view.dy
     def render(self,plot):
         """The base class makes sure the correct units are being used for
@@ -412,9 +427,14 @@
     def check_data_PlottableY(self): 
         self.view.check_data_logY() 
+        
     def returnTransformationx(self,transx,transdx):
         self.view.returntransformx(transx,transdx)
+        
     def returnTransformationy(self,transy,transdy):
         self.view.returntransformy(transy,transdy)
-   
+    def onReset(self):
+        self.view.onResetView()
+    def onFitRange(self,xmin,xmax):
+        self.view.onFitRangeView(xmin,xmax)
     class View:
         """
@@ -432,7 +452,13 @@
             self.dx = dx
             self.dy = dy
-           
+            #to change x range to the reel range
+            self.Xreel = self.x
+            self.Yreel = self.y
+            self.DXreel = self.dx
+            self.DYreel = self.dy
+            
             self.transx =""
             self.transy =""
+            # function to transform x and y
             self.funcx= None
             self.funcy= None
@@ -463,5 +489,6 @@
                 self.dx = []
                 self.dy = []
-               
+                tempx=[]
+                tempy=[]
                 if dx==None:
                     dx=numpy.zeros(len(x))
@@ -481,12 +508,12 @@
                          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 sys.exc_value  
-                print len(self.x)
-                print len(self.dx)
-                print len(self.y)
-                print len(self.dy)
+               
                 # Sanity check
                 if not (len(self.x)==len(self.dx))and(len(self.x)==len(self.dy))\
@@ -495,8 +522,13 @@
                 self.check_data_logX()
                 self.check_data_logY()
-                print len(self.x)
-                print len(self.dx)
-                print len(self.y)
-                print len(self.dy)
+                self.Xreel = self.x
+                self.Yreel = self.y
+                self.DXreel = self.dx
+                self.DYreel = self.dy
+        def onResetView(self):
+            self.x=self.Xreel
+            self.y=self.Yreel
+            self.dx=self.DXreel
+            self.dy=self.DYreel
         def returntransformx(self,funcx,funcdx):    
             self.funcx= funcx
@@ -574,5 +606,19 @@
                 self.dy=tempdy
                 
-            
+        def onFitRangeView(self,xmin,xmax):
+            tempx=[]
+            tempdx=[]
+            tempy=[]
+            tempdy=[]
+            for i in range(len(self.x)):
+                if ( self.x[i] >= xmin ) and ( self.x[i] <= xmax ):
+                    tempx.append(self.x[i])
+                    tempdx.append(self.dx[i])
+                    tempy.append(self.y[i])
+                    tempdy.append(self.dy[i])
+            self.x=tempx
+            self.y=tempy
+            self.dx=tempdx
+            self.dy=tempdy        
 
 class Data1D(Plottable):
