code: def save_cb(self, mode):
          
  
          # This just defines the basename.
          # Extension has to be explicitly defined or things can get messy.
          w = Widgets.SaveDialog(title='Save {0} data'.format(mode))
          filename = w.get_path()
  
          if filename is None:
              # user canceled dialog
              return
  
          # TODO: This can be a user preference?
          fig_dpi = 100
  
          if mode == 'cuts':
              fig, xarr, yarr = self.cuts_plot.get_data()
  
          elif mode == 'slit':
              fig, xarr, yarr = self.slit_plot.get_data()
  
          figname = filename + '.png'
          self.logger.info("saving figure as: %s" % (figname))
          fig.savefig(figname, dpi=fig_dpi)
  
          dataname = filename + '.npz'
          self.logger.info("saving data as: %s" % (dataname))
          np.savez_compressed(dataname, x=xarr, y=yarr)
docs: Save image, figure, and plot data arrays.