code: def _rotate_cmap(cmap, swap_order=("green", "red", "blue")):
      """Utility function to swap the colors of a colormap."""
      orig_cdict = cmap._segmentdata.copy()
  
      cdict = {}
      cdict["green"] = list(orig_cdict[swap_order[0]])
      cdict["blue"] = list(orig_cdict[swap_order[1]])
      cdict["red"] = list(orig_cdict[swap_order[2]])
  
      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 1 for calling a global function with example usage: _rotate_cmap(cmap, swap_order) and returns: cdict