Commits

Georg Brandl committed eca87d7

plotting: some graphical improvements

Comments (0)

Files changed (3)

ufit/data/dataset.py

         new_array = rebin(alldata, binsize)
         sources = sum((dset.sources for dset in allsets), [])
         new_meta = self.meta.copy()
+        for col in self.meta:
+            if not col.startswith('col_'):
+                continue
+            new_meta[col] = concatenate([dset.meta[col] for dset in allsets])
         # XXX hkl data is a mess
         if 'is_hkldata' in self.meta and binsize == 0:
             new_meta['hkle'] = concatenate([dset.meta['hkle']
         self.axes.clear()
         self.marker_cycle = cycle(self.markers)
 
-    def plot_data(self, data, multi=False):
+    def plot_data(self, data, multi=False, ms=8):
         """Plot dataset."""
         axes = self.axes
         marker = self.marker_cycle.next() if self.symbols else ''
         ls = '-' if self.lines else ''
         if data.mask.all():
             eb = axes.errorbar(data.x_plot, data.y, data.dy, ls=ls, marker=marker,
-                               ms=8, label=data.name, picker=5)
+                               ms=ms, label=data.name, picker=5)
             color = eb[0].get_color()
         else:
             mask = data.mask
             eb = axes.errorbar(data.x_plot[mask], data.y[mask], data.dy[mask], ls=ls,
-                               marker=marker, ms=8, label=data.name, picker=5)
+                               marker=marker, ms=ms, label=data.name, picker=5)
             color = eb[0].get_color()
             axes.errorbar(data.x_plot[~mask], data.y[~mask], data.dy[~mask], ls='',
-                          marker=marker, ms=8, picker=5, mfc='white', mec=color,
+                          marker=marker, ms=ms, picker=5, mfc='white', mec=color,
                           label='')
         if not multi:
             if data.fitmin is not None:
         xx = multi_linspace(data.x[imin], data.x[imax], nsamples)
         xxp = linspace(data.x_plot[imin], data.x_plot[imax], nsamples)
         yy = model.fcn(paramvalues, xx)
-        self.axes.plot(xxp, yy, 'g', lw=2, label=labels and 'fit' or '', **kw)
+        self.axes.plot(xxp, yy, 'g', lw=kw.pop('kw', 2),
+                       label=labels and 'fit' or '', **kw)
         for comp in model.get_components():
             if comp is model:
                 continue
         xx = multi_linspace(data.x[imin], data.x[imax], nsamples)
         xxp = linspace(data.x_plot[imin], data.x_plot[imax], nsamples)
         yy = model.fcn(paramvalues, xx)
-        self.axes.plot(xxp, yy, kw.pop('fmt', 'g'), lw=2,
+        self.axes.plot(xxp, yy, kw.pop('fmt', 'g'), lw=kw.pop('lw', 2),
                        label=labels and 'fit' or '', **kw)
 
     def plot_model_components(self, model, data, labels=True, paramvalues=None,
                    min(yss):max(yss):interpolate]
     zi = griddata_sp(array((xss, yss)).T, zss, (xi, yi))
     if mat:
-        im = axes.imshow(zi.T, origin='lower', aspect='auto',
+        im = axes.imshow(zi.T, origin='lower', aspect='auto', interpolation='nearest',
                          extent=(xi[0][0]/xscale, xi[-1][-1]/xscale,
                                  yi[-1][-1]/yscale, yi[0][0]/yscale))
     else:
     axes.set_ylabel(y)
     figure.colorbar(im)
     if dots:
-        axes.scatter(xss, yss, 0.5)
+        axes.scatter(xss, yss, 0.1)
         print '%-15s = %10.4g' % ('chi^2/NDF', self.chisqr)
         print '=' * 80
 
-    def plot(self, axes=None, params=True):
+    def plot(self, axes=None, params=True, multi=False):
         """Plot the data and model together in the current figure.
 
         If *params* is true, also plot parameter values as text.
         """
         plotter = DataPlotter(axes=axes)
-        plotter.plot_data(self.data)
-        plotter.plot_model(self.model, self.data, paramvalues=self.paramvalues)
-        if params:
+        c = plotter.plot_data(self.data, multi=multi)
+        plotter.plot_model(self.model, self.data, paramvalues=self.paramvalues,
+                           labels=not multi, color=c)
+        if params and not multi:
             plotter.plot_params(self.params, self.chisqr)
 
     def plotfull(self, axes=None, params=True):
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.