code: def timeseries_as_heatmap(X, var_names=None, highlightsX=None, color_map=None):
      
      if highlightsX is None:
          highlightsX = []
      if var_names is None:
          var_names = []
      if len(var_names) == 0:
          var_names = np.arange(X.shape[1])
      if var_names.ndim == 2:
          var_names = var_names[:, 0]
  
      # transpose X
      X = X.T
      minX = np.min(X)
  
      # insert space into X
      if False:
          # generate new array with highlightsX
          space = 10  # integer
          Xnew = np.zeros((X.shape[0], X.shape[1] + space*len(highlightsX)))
          hold = 0
          _hold = 0
          space_sum = 0
          for ih, h in enumerate(highlightsX):
              _h = h + space_sum
              Xnew[:, _hold:_h] = X[:, hold:h]
              Xnew[:, _h:_h+space] = minX * np.ones((X.shape[0], space))
              # update variables
              space_sum += space
              _hold = _h + space
              hold = h
          Xnew[:, _hold:] = X[:, hold:]
  
      fig = pl.figure(figsize=(1.5*4, 2*4))
      im = pl.imshow(np.array(X, dtype=np.float_), aspect='auto',
                     interpolation='nearest', cmap=color_map)
      pl.colorbar(shrink=0.5)
      pl.yticks(range(X.shape[0]), var_names)
      for ih, h in enumerate(highlightsX):
          pl.plot([h, h], [0, X.shape[0]], '--', color='black')
      pl.xlim([0, X.shape[1]-1])
      pl.ylim([0, X.shape[0]-1])
docs: Plot timeseries as heatmap.
  
      Parameters
      ----------
      X : np.ndarray
          Data array.
      var_names : array_like
          Array of strings naming variables stored in columns of X.