Commits

Georg Brandl committed c36be95

result: plot parameter values as well

Comments (0)

Files changed (3)

             self.axes.plot(xx, yy, '-.', label=labels and comp.name or '',
                            **kw)
 
+    def plot_params(self, params):
+        s = '\n'.join(str(p) for p in params)
+        self.axes.text(0.02, 0.98, s, horizontalalignment='left',
+                       verticalalignment='top', size='x-small',
+                       transform=self.axes.transAxes)
+
 
 def mapping(x, y, runs, minmax=None, mat=False, log=False):
     pl.clf()
         self.chisqr = chisqr
         self.paramdict = dict((p.name, p) for p in params)
         self.paramvalues = dict((p.name, p.value) for p in params)
+        # XXX make a property
+        self.residuals = model.fcn(self.paramvalues, data.x) - data.y
 
+    # XXX make lazy
     @property
     def xx(self):
         return linspace(self.data.x[0], self.data.x[-1], 1000)
         print '%-15s = %10.4g' % ('chi^2/NDF', self.chisqr)
         print '=' * 80
 
-    def plot(self, axes=None):
+    def plot(self, axes=None, params=True):
         """Plot the data and model together in the current figure."""
-        plotter = DataPlotter()
-        plotter.plot_data(self.data, axes=axes)
-        plotter.plot_model(self.model, self.data, axes=axes)
+        # XXX plot parameters in here
+        plotter = DataPlotter(axes)
+        plotter.plot_data(self.data)
+        plotter.plot_model(self.model, self.data)
+        if params:
+            plotter.plot_params(self.params)
 
-    def plotfull(self, axes=None):
+    def plotfull(self, axes=None, params=True):
         """Plot the data and model, including subcomponents, together in the
         current figure.
         """
-        plotter = DataPlotter()
-        plotter.plot_data(self.data, axes=axes)
-        plotter.plot_model_full(self.model, self.data, axes=axes)
+        plotter = DataPlotter(axes)
+        plotter.plot_data(self.data)
+        plotter.plot_model_full(self.model, self.data)
+        if params:
+            plotter.plot_params(self.params)
         try:
             return self[key]
         except KeyError:
-            raise AttributeError
+            raise AttributeError(key)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.