docs: def plotRates (include =['allCells', 'eachPop'], peakBin = 5, timeRanges = None, timeRangeLabels = None, colors = None, figSize = ((5,5)), saveData = None, 
          ylim = None, saveFig = None, showFig = True):
      ''' 
      Calculate avg and peak rate of different subsets of cells for specific time period
          - include (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])]): List of data series to include. 
              Note: one line per item, not grouped (default: ['allCells', 'eachPop'])
          - timeRanges ([[start1:stop1], [start2:stop2]]): List of time range of spikes shown; if None shows all (default: None)
          - timeRangeLabels (['preStim', 'postStim']): List of labels for each time range period (default: None)
          - peakBin (int): Histogram bin size used to calculate peak firing rate; if None, peak rate not calculated (default: 5)
          - figSize ((width, height)): Size of figure (default: (10,8))
          - saveData (None|True|'fileName'): File name where to save the final data used to generate the figure; 
              if set to True uses filename from simConfig (default: None)
          - saveFig (None|True|'fileName'): File name where to save the figure (default: None)
              if set to True uses filename from simConfig (default: None)
          - showFig (True|False): Whether to show the figure or not (default: True)
  
          - Returns figs
      '''
      from .. import sim
  
      if not colors: colors = colorList
  
      avgs = []
      peaks = []
      if not timeRangeLabels:
          timeRangeLabels = ['%f-%f ms'%(t[0], t[1]) for t in timeRanges] #['period '+i for i in range(len(timeRanges))]
  
      for i, timeRange in enumerate(timeRanges):
          labels, avg, peak = sim.analysis.calculateRate(include=include, peakBin=peakBin, timeRange=timeRange)
          avgs.append(avg)
          peaks.append(peak)
  
      if showFig or saveFig:
          fig1,ax1 = plt.subplots(figsize=figSize)
  
          # avg
          fontsiz=14
          ax1.set_color_cycle(colors)
          ax1.plot(avgs, marker='o')
          #ax1.set_xlabel('Time period', fontsize=fontsiz)
          ax1.set_ylabel('Avg firing rate', fontsize=fontsiz)
          ax1.set_xticks(list(range(len(timeRangeLabels))))
          ax1.set_xticklabels(timeRangeLabels, fontsize=fontsiz)
          ax1.set_xlim(-0.5, len(avgs)-0.5)
          if ylim: ax1.set_ylim(ylim)
          ax1.legend(include)
  
          try:
              plt.tight_layout()
          except:
              pass
  
          # save figure
          if saveFig: 
              if isinstance(saveFig, basestring):
                  filename = saveFig
              else:
                  filename = sim.cfg.filename+'_'+'avgRates.png'
              plt.savefig(filename)
  
          # show fig 
          if showFig: _showFigure()
  
          # peak
          fig2,ax2 = plt.subplots(figsize=figSize)
          ax2.set_color_cycle(colors)
          ax2.plot(peaks, marker='o')
          #ax2.set_xlabel('Time period', fontsize=fontsiz)
          ax2.set_ylabel('Peak firing rate', fontsize=fontsiz)
          ax2.set_xticks(list(range(len(timeRangeLabels))))
          ax2.set_xticklabels(timeRangeLabels)
          ax2.set_xlim(-0.5, len(peaks)-0.5)
          if ylim: ax2.set_ylim(ylim)
          ax2.legend(include)
  
          try:
              plt.tight_layout()
          except:
              pass
  
          # save figure
          if saveFig: 
              if isinstance(saveFig, basestring):
                  filename = saveFig
              else:
                  filename = sim.cfg.filename+'_'+'peakRates.png'
              plt.savefig(filename)
  
          # show fig 
          if showFig: _showFigure()
      else:
          fig1, fig2 = None, None
  
          
      # save figure data
      if saveData:
          figData = {'includeList': includeList, 'timeRanges': timeRanges, 'avgs': avgs, 'peaks': peaks}
  
          _saveFigData(figData, saveData, 'raster')
  
      return fig1, fig2, avgs, peaks