code: def _concat_cmap(cmap1, cmap2):
      """Utility function to make a new colormap by concatenating two
      colormaps.
      """
      cdict = {}
  
      cdict1 = cmap1._segmentdata.copy()
      cdict2 = cmap2._segmentdata.copy()
      if not hasattr(cdict1["red"], "__call__"):
          for c in ["red", "green", "blue"]:
              cdict[c] = [
                  (0.5 * p, c1, c2) for (p, c1, c2) in cdict1[c]
              ]
      else:
          for c in ["red", "green", "blue"]:
              cdict[c] = []
          ps = _np.linspace(0, 1, 10)
          colors = cmap1(ps)
          for p, (r, g, b, a) in zip(ps, colors):
              cdict["red"].append((0.5 * p, r, r))
              cdict["green"].append((0.5 * p, g, g))
              cdict["blue"].append((0.5 * p, b, b))
      if not hasattr(cdict2["red"], "__call__"):
          for c in ["red", "green", "blue"]:
              cdict[c].extend(
                  [(0.5 * (1 + p), c1, c2) for (p, c1, c2) in cdict2[c]]
              )
      else:
          ps = _np.linspace(0, 1, 10)
          colors = cmap2(ps)
          for p, (r, g, b, a) in zip(ps, colors):
              cdict["red"].append((0.5 * (1 + p), r, r))
              cdict["green"].append((0.5 * (1 + p), g, g))
              cdict["blue"].append((0.5 * (1 + p), b, b))
  
      return cdict
  
file_path: nipy/nipy/labs/viz_tools/cm.py
imports: import numpy
  from matplotlib import cm
  from matplotlib import colors
  from matplotlib import rcParams
label_desc: Use image node_id 3 for calling a global function with example usage: _concat_cmap(cmap1, cmap2) and returns: cdict