Index: guitools/PlotPanel.py
===================================================================
--- guitools/PlotPanel.py	(revision 05da1f8994b512c6a943f61974e1f83b0508cfab)
+++ guitools/PlotPanel.py	(revision b6972a0ff9c77ad6772251f467178f745e5dc095)
@@ -20,5 +20,6 @@
 from plottables import Graph
 #(FuncFitEvent, EVT_FUNC_FIT) = wx.lib.newevent.NewEvent()
-import math,pylab
+import math,pylab,re
+
 def show_tree(obj,d=0):
     """Handy function for displaying a tree of graph objects"""
@@ -26,4 +27,24 @@
     if 'get_children' in dir(obj):
         for a in obj.get_children(): show_tree(a,d+1)
+        
+def convertUnit(pow,unit):
+    """ 
+        Displays the unit with the proper convertion
+        @param pow: the user set the power of the unit
+        @param unit: the unit of the data
+    """ 
+    toks=re.match("^", unit)
+    if not toks==None:
+        unitValue= re.split("{",unit)
+        unitPower= re.split("}",unitValue[1])
+        power= int(unitPower[0])*pow
+        word= unitValue[0]+"{"+str(power)+"}"
+        if power==1:
+            tempUnit=re.split("\^",unitValue[0])
+            unit=tempUnit[0]
+        else:
+            unit = word
+    #print"this is unit",unit
+    return unit
 def _rescale(lo,hi,step,pt=None,bal=None,scale='linear'):
         """
@@ -487,5 +508,6 @@
                 self.set_xscale("linear")
                 name, units = item.get_xaxis()
-                self.graph.xaxis("%s" % name,  "%s^{-1}" % units)
+                self.graph.xaxis("%s" % name,  "%s" % units)
+                
                 
             if ( self.xLabel=="x^(2)" ):
@@ -493,5 +515,7 @@
                 self.set_xscale('linear')
                 name, units = item.get_xaxis()
-                self.graph.xaxis("%s^{2}" % name,  "%s^{-2}" % units)
+                units=convertUnit(2,units) 
+                self.graph.xaxis("%s^{2}" % name,  "%s" % units)
+                
                 
             if (self.xLabel=="log10(x)" ):
@@ -499,5 +523,6 @@
                 self.set_xscale("log")
                 name, units = item.get_xaxis() 
-                self.graph.xaxis("\log_{10}\ \  (%s)" % name,  "%s^{-1}" % units)
+                self.graph.xaxis("\log_{10}\ \  (%s)" % name,  "%s" % units)
+                
                 
             if ( self.yLabel=="ln(y)" ):
@@ -505,5 +530,6 @@
                 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" % units)
+                
                 
             if ( self.yLabel=="y" ):
@@ -511,5 +537,6 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("%s" % name,  "%s^{-1}" % units)
+                self.graph.yaxis("%s" % name,  "%s" % units)
+               
                 
             if ( self.yLabel=="log10(y)" ): 
@@ -517,5 +544,6 @@
                 self.set_yscale("log")  
                 name, units = item.get_yaxis()
-                self.graph.yaxis("\log_{10}\ \ (%s)" % name,  "%s^{-1}" % units)
+                self.graph.yaxis("\log_{10}\ \ (%s)" % name,  "%s" % units)
+                
                 
             if ( self.yLabel=="y^(2)" ):
@@ -523,5 +551,7 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("%s^{2}" % name,  "%s^{-2}" % units)
+                units=convertUnit(2,units) 
+                self.graph.yaxis("%s^{2}" % name,  "%s" % units)
+                
                 
             if ( self.yLabel =="1/y"):
@@ -529,5 +559,6 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
-                self.graph.yaxis("1/%s" % name,  "\ \%s" % units)
+                units=convertUnit(-1,units)
+                self.graph.yaxis("1/%s" % name,  "%s" % units)
                 
             if ( self.yLabel =="1/sqrt(y)" ):
@@ -535,4 +566,5 @@
                 self.set_yscale("linear")
                 name, units = item.get_yaxis()
+                units=convertUnit(-1,units)
                 self.graph.yaxis("1/\sqrt{%s}" %name,  "%s" % units)
                 
@@ -542,5 +574,6 @@
                 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%s" % (yunits,xunits))
+               
                 
             if ( self.yLabel =="ln(y*x^(2))"):
@@ -549,5 +582,7 @@
                 yname, yunits = item.get_yaxis()
                 xname, xunits = item.get_xaxis() 
-                self.graph.yaxis("Log (%s \ \ %s^{2})" % (yname,xname),  "%s^{-1}%s^{-2}" % (yunits,xunits))
+                xunits = convertUnit(2,xunits) 
+                self.graph.yaxis("Log (%s \ \ %s)" % (yname,xname),  "%s%s" % (yunits,xunits))
+                
             
             if ( self.yLabel =="ln(y*x^(4))"):
@@ -556,6 +591,7 @@
                 yname, yunits = item.get_yaxis()
                 xname, xunits = item.get_xaxis()
-                self.graph.yaxis("Log (%s \ \ %s^{4})" % (yname,xname),  "%s^{-1}%s^{-4}" % (yunits,xunits))
-            
+                xunits = convertUnit(4,xunits) 
+                self.graph.yaxis("Log (%s \ \ %s)" % (yname,xname),  "%s%s" % (yunits,xunits))
+                
             if ( self.viewModel == "Guinier lny vs x^(2)"):
                 
@@ -563,14 +599,17 @@
                 self.set_xscale('linear')
                 name, units = item.get_xaxis()
-                self.graph.xaxis("%s^{2}" % name,  "%s^{-2}" % units)
+                units = convertUnit(2,units) 
+                self.graph.xaxis("%s^{2}" % name,  "%s" % units)
+                
                 
                 item.transformY(transform.toLogX,transform.errToLogX )
                 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" % units)
+               
                 
             item.transformView()
             
-        #item.name = self.yLabel+" vs " +self.xLabel  
+         
         self.resetFitView()   
         self.prevXtrans = self.xLabel 
@@ -579,4 +618,6 @@
         self.subplot.figure.canvas.draw_idle()
         
+        
+    
     def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax,func):
         """
