docs: def plotConn (includePre = ['all'], includePost = ['all'], feature = 'strength', orderBy = 'gid', figSize = (10,10), groupBy = 'pop', groupByIntervalPre = None, groupByIntervalPost = None, graphType = 'matrix', synOrConn = 'syn', synMech = None, connsFile = None, tagsFile = None, clim = None, fontSize = 12, saveData = None, saveFig = None, showFig = True): 
      ''' 
      Plot network connectivity
          - includePre (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])]): Cells to show (default: ['all'])
          - includePost (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])]): Cells to show (default: ['all'])
          - feature ('weight'|'delay'|'numConns'|'probability'|'strength'|'convergence'|'divergence'): Feature to show in connectivity matrix; 
              the only features applicable to groupBy='cell' are 'weight', 'delay' and 'numConns';  'strength' = weight * probability (default: 'strength')
          - groupBy ('pop'|'cell'|'y'|: Show matrix for individual cells, populations, or by other numeric tag such as 'y' (default: 'pop')
          - groupByInterval (int or float): Interval of groupBy feature to group cells by in conn matrix, e.g. 100 to group by cortical depth in steps of 100 um   (default: None)
          - orderBy ('gid'|'y'|'ynorm'|...): Unique numeric cell property to order x and y axes by, e.g. 'gid', 'ynorm', 'y' (requires groupBy='cells') (default: 'gid')
          - graphType ('matrix','bar','pie'): Type of graph to represent data (default: 'matrix')
          - synOrConn ('syn'|'conn'): Use synapses or connections; note 1 connection can have multiple synapses (default: 'syn')
          - figSize ((width, height)): Size of figure (default: (10,10))
          - synMech (['AMPA', 'GABAA',...]): Show results only for these syn mechs (default: None)
          - 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; 
              if set to True uses filename from simConfig (default: None)
          - showFig (True|False): Whether to show the figure or not (default: True)
  
          - Returns figure handles
      '''
      
      from .. import sim
  
      print('Plotting connectivity matrix...')
  
      if connsFile and tagsFile:
          connMatrix, pre, post = _plotConnCalculateFromFile(includePre, includePost, feature, orderBy, groupBy, groupByIntervalPre, groupByIntervalPost, synOrConn, synMech, connsFile, tagsFile)
      else:
          connMatrix, pre, post = _plotConnCalculateFromSim(includePre, includePost, feature, orderBy, groupBy, groupByIntervalPre, groupByIntervalPost, synOrConn, synMech)
  
  
      if connMatrix is None:
          print("Error calculating connMatrix in plotConn()")
          return None
  
      # set font size
      plt.rcParams.update({'font.size': fontSize})
  
      # matrix plot
      if graphType == 'matrix':
          # Create plot
          fig = plt.figure(figsize=figSize)
          fig.subplots_adjust(right=0.98) # Less space on right
          fig.subplots_adjust(top=0.96) # Less space on top
          fig.subplots_adjust(bottom=0.02) # Less space on bottom
          h = plt.axes()
  
          plt.imshow(connMatrix, interpolation='nearest', cmap='viridis', vmin=np.nanmin(connMatrix), vmax=np.nanmax(connMatrix))  #_bicolormap(gap=0)
  
          # Plot grid lines
              
          if groupBy == 'cell':
              cellsPre, cellsPost = pre, post
  
              # Make pretty
              stepy = max(1, int(len(cellsPre)/10.0))
              basey = 100 if stepy>100 else 10
              stepy = max(1, int(basey * np.floor(float(stepy)/basey)))
              stepx = max(1, int(len(cellsPost)/10.0))
              basex = 100 if stepx>100 else 10
              stepx = max(1, int(basex * np.floor(float(stepx)/basex)))
  
              h.set_xticks(np.arange(0,len(cellsPost),stepx))
              h.set_yticks(np.arange(0,len(cellsPre),stepy))
              h.set_xticklabels(np.arange(0,len(cellsPost),stepx))
              h.set_yticklabels(np.arange(0,len(cellsPost),stepy))
              h.xaxis.set_ticks_position('top')
              plt.xlim(-0.5,len(cellsPost)-0.5)
              plt.ylim(len(cellsPre)-0.5,-0.5)
  
          elif groupBy == 'pop':
              popsPre, popsPost = pre, post
  
              for ipop, pop in enumerate(popsPre):
                  plt.plot(np.array([0,len(popsPre)])-0.5,np.array([ipop,ipop])-0.5,'-',c=(0.7,0.7,0.7))
              for ipop, pop in enumerate(popsPost):
                  plt.plot(np.array([ipop,ipop])-0.5,np.array([0,len(popsPost)])-0.5,'-',c=(0.7,0.7,0.7))
  
              # Make pretty
              h.set_xticks(list(range(len(popsPost))))
              h.set_yticks(list(range(len(popsPre))))
              h.set_xticklabels(popsPost)
              h.set_yticklabels(popsPre)
              h.xaxis.set_ticks_position('top')
              plt.xlim(-0.5,len(popsPost)-0.5)
              plt.ylim(len(popsPre)-0.5,-0.5)
  
          else:
              groupsPre, groupsPost = pre, post
  
              for igroup, group in enumerate(groupsPre):
                  plt.plot(np.array([0,len(groupsPre)])-0.5,np.array([igroup,igroup])-0.5,'-',c=(0.7,0.7,0.7))
              for igroup, group in enumerate(groupsPost):
                  plt.plot(np.array([igroup,igroup])-0.5,np.array([0,len(groupsPost)])-0.5,'-',c=(0.7,0.7,0.7))
  
              # Make pretty
              h.set_xticks([i-0.5 for i in range(len(groupsPost))])
              h.set_yticks([i-0.5 for i in range(len(groupsPre))])
              h.set_xticklabels([int(x) if x>1 else x for x in groupsPost])
              h.set_yticklabels([int(x) if x>1 else x for x in groupsPre])
              h.xaxis.set_ticks_position('top')
              plt.xlim(-0.5,len(groupsPost)-0.5)
              plt.ylim(len(groupsPre)-0.5,-0.5)
  
          if not clim: clim = [np.nanmin(connMatrix), np.nanmax(connMatrix)]
          plt.clim(clim[0], clim[1])
          plt.colorbar(label=feature, shrink=0.8) #.set_label(label='Fitness',size=20,weight='bold')
          plt.xlabel('post')
          h.xaxis.set_label_coords(0.5, 1.06)
          plt.ylabel('pre')
          plt.title ('Connection '+feature+' matrix', y=1.08)
  
      # stacked bar graph
      elif graphType == 'bar':
          if groupBy == 'pop':
              popsPre, popsPost = pre, post
  
              from netpyne.support import stackedBarGraph 
              SBG = stackedBarGraph.StackedBarGrapher()
      
              fig = plt.figure(figsize=figSize)
              ax = fig.add_subplot(111)
              SBG.stackedBarPlot(ax, connMatrix.transpose(), colorList, xLabels=popsPost, gap = 0.1, scale=False, xlabel='postsynaptic', ylabel = feature)
              plt.title ('Connection '+feature+' stacked bar graph')
              plt.legend(popsPre)
              plt.tight_layout()
  
          elif groupBy == 'cell':
              print('Error: plotConn graphType="bar" with groupBy="cell" not implemented')
  
      elif graphType == 'pie':
          print('Error: plotConn graphType="pie" not yet implemented')
  
  
      #save figure data
      if saveData:
          figData = {'connMatrix': connMatrix, 'feature': feature, 'groupBy': groupBy,
           'includePre': includePre, 'includePost': includePost, 'saveData': saveData, 'saveFig': saveFig, 'showFig': showFig}
      
          _saveFigData(figData, saveData, 'conn')
   
      # save figure
      if saveFig: 
          if isinstance(saveFig, basestring):
              filename = saveFig
          else:
              filename = sim.cfg.filename+'_'+'conn_'+feature+'.png'
          plt.savefig(filename)
  
      # show fig 
      if showFig: _showFigure()
  
      return fig, {'connMatrix': connMatrix, 'feature': feature, 'groupBy': groupBy, 'includePre': includePre, 'includePost': includePost}