Index: prview/perspectives/pr/inversion_panel.py
===================================================================
--- prview/perspectives/pr/inversion_panel.py	(revision 5d983700d64a91e89e31ec3d38a6b87deea505ee)
+++ prview/perspectives/pr/inversion_panel.py	(revision d2ee6f65fa92abccd361d363fee80f855f73e64b)
@@ -207,9 +207,7 @@
             if self.standalone==False:
                 self.plot_data.SetValue(str(value))
-                self.plot_radio.SetValue(True)
                 self._on_pars_changed(None)
         elif name=='datafile':
             self.data_file.SetValue(str(value))
-            self.file_radio.SetValue(True)
             self._on_pars_changed(None)
         else:
@@ -433,21 +431,15 @@
 
         iy = 0
-        if self.standalone==False:
-            self.file_radio = wx.RadioButton(self, -1, "File data:")
+        self.file_radio = wx.StaticText(self, -1, "Data:")
+        pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        
+        if self.standalone==True:
+            self.data_file = wx.TextCtrl(self, -1, size=(220,20))
+            self.data_file.SetEditable(False)
+            self.data_file.SetValue("")
+            pars_sizer.Add(self.data_file, (iy,1), (1,1), wx.ADJUST_MINSIZE, 15)
         else:
-            self.file_radio = wx.StaticText(self, -1, "Data file:")
-        self.data_file = wx.TextCtrl(self, -1, size=(220,20))
-        self.data_file.SetEditable(False)
-        self.data_file.SetValue("")
-        id = wx.NewId()
-        pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        pars_sizer.Add(self.data_file, (iy,1), (1,1), wx.ADJUST_MINSIZE, 15)
-        
-        if self.standalone==False:
-            iy += 1
-            self.plot_radio = wx.RadioButton(self, -1, "Plot data:")
-            self.plot_data = wx.TextCtrl(self, -1, size=(100,20))
+            self.plot_data = wx.TextCtrl(self, -1, size=(220,20))
             self.plot_data.SetEditable(False)
-            pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
             pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         
@@ -788,5 +780,5 @@
             self.alpha_estimate_ctl.Enable(False)
             
-            if self.standalone==False and self.plot_radio.GetValue():
+            if self.standalone==False:
                 dataset = self.plot_data.GetValue()
                 self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, 
@@ -923,5 +915,5 @@
         
         if flag:
-            if self.standalone==False and self.plot_radio.GetValue():
+            if self.standalone==False:
                 dataset = self.plot_data.GetValue()
                 if len(dataset.strip())==0:
@@ -962,6 +954,4 @@
             if path and os.path.isfile(path):
                 self.data_file.SetValue(str(path))
-                if self.standalone==False:
-                    self.file_radio.SetValue(True)
                 self.manager.show_data(path, reset=True)
                 self._on_pars_changed(None)
Index: prview/perspectives/pr/pr.py
===================================================================
--- prview/perspectives/pr/pr.py	(revision 6f1f1292247c9b4409a230bcaf88a956ec42edf1)
+++ prview/perspectives/pr/pr.py	(revision d2ee6f65fa92abccd361d363fee80f855f73e64b)
@@ -29,5 +29,5 @@
     DEFAULT_DMAX  = 140.0
     
-    def __init__(self):
+    def __init__(self, standalone=True):
         ## Plug-in name
         self.sub_menu = "Pr inversion"
@@ -77,5 +77,5 @@
         self._pr_npts = 51
         ## Flag to let the plug-in know that it is running standalone
-        self.standalone = True
+        self.standalone = standalone
         self._normalize_output = False
         self._scale_output_unity = False
@@ -257,6 +257,12 @@
         new_plot.xaxis("\\rm{Q}", 'A^{-1}')
         new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
-        #new_plot.group_id = "test group"
-        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="I(q)"))
+        
+        title = "I(q)"
+        # If we have a group ID, use it
+        if pr.info.has_key("plot_group_id"):
+            new_plot.group_id = pr.info["plot_group_id"]
+            title = pr.info["plot_group_id"]
+            
+        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title))
         
         # If we have used slit smearing, plot the smeared I(q) too
@@ -342,5 +348,7 @@
         new_plot.xaxis("\\rm{r}", 'A')
         new_plot.yaxis("\\rm{P(r)} ","cm^{-3}")
-            
+        # Make sure that the plot is linear
+        new_plot.xtransform="x"
+        new_plot.ytransform="y"                 
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="P(r) fit"))
         
@@ -538,4 +546,6 @@
 
             elif item.name==graph.selected_plottable:
+	            #TODO: we might want to check that the units are consistent with I(q)
+	            #      before allowing this menu item
                 return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]]      
                 
@@ -876,15 +886,33 @@
         pr.slit_width = self.slit_width
         
+        # Keep track of the plot window title to ensure that
+        # we can overlay the plots
+        if hasattr(self.current_plottable, "group_id"):
+            pr.info["plot_group_id"] = self.current_plottable.group_id
+        
         # Fill in errors if none were provided
-        if self.current_plottable.dy == None:
-            print "no error", self.current_plottable.name
-            y = numpy.zeros(len(pr.y))
+        err = self.current_plottable.dy
+        all_zeros = True
+        if err == None:
+            err = numpy.zeros(len(y)) 
+        else:    
+            for i in range(len(err)):
+                if err[i]>0:
+                    all_zeros = False
+        
+        if all_zeros:        
+            scale = None
+            min_err = 0.0
             for i in range(len(pr.y)):
-                y[i] = math.sqrt(pr.y[i])
-            pr.err = y
-        else:
-            pr.err = self.current_plottable.dy
-        
-        #self.pr = pr
+                # Scale the error so that we can fit over several decades of Q
+                if scale==None:
+                    scale = 0.05*math.sqrt(pr.y[i])
+                    min_err = 0.01*pr.y[i]
+                err[i] = scale*math.sqrt( math.fabs(pr.y[i]) ) + min_err
+            message = "The loaded file had no error bars, statistical errors are assumed."
+            wx.PostEvent(self.parent, StatusEvent(status=message))
+
+        pr.err = err
+        
         return pr
 
@@ -1160,5 +1188,6 @@
             [Somehow openGL needs this call]
         """
-        self.parent.set_perspective(self.perspective)
+        if self.standalone==True:
+            self.parent.set_perspective(self.perspective)
   
 if __name__ == "__main__":
