code: def plotres(psr,deleted=False,group=None,**kwargs):
      
  
      res, t, errs = psr.residuals(), psr.toas(), psr.toaerrs
      
      if (not deleted) and N.any(psr.deleted != 0):
          res, t, errs = res[psr.deleted == 0], t[psr.deleted == 0], errs[psr.deleted == 0]
          print("Plotting {0}/{1} nondeleted points.".format(len(res),psr.nobs))
  
      meanres = math.sqrt(N.mean(res**2)) / 1e-6
      
      if group is None:
          i = N.argsort(t)
          P.errorbar(t[i],res[i]/1e-6,yerr=errs[i],fmt='x',**kwargs)
      else:
          if (not deleted) and N.any(psr.deleted):
              flagmask = psr.flagvals(group)[~psr.deleted]
          else:
              flagmask = psr.flagvals(group)
  
          unique = list(set(flagmask))
              
          for flagval in unique:
              f = (flagmask == flagval)
              flagres, flagt, flagerrs = res[f], t[f], errs[f]
              i = N.argsort(flagt)
              P.errorbar(flagt[i],flagres[i]/1e-6,yerr=flagerrs[i],fmt='x',**kwargs)
          
          P.legend(unique,numpoints=1,bbox_to_anchor=(1.1,1.1))
  
      P.xlabel('MJD'); P.ylabel('res [us]')
      P.title("{0} - rms res = {1:.2f} us".format(psr.name,meanres))
docs: Plot residuals, compute unweighted rms residual.