code: def shifted_color_map(
      cmap,
      start=0,
      midpoint=0.5,
      stop=1.0,
      name: str = "shiftedcmap",
      transparent_from: float = None,
  ):
      """Offset the "center" of a colormap.
  
       Parameters
      ----------
      cmap
          The matplotlib colormap to be altered
      start , default: 0
          Offset from lowest point in the colormap's range.
          Should be between0.0 and 1.0.
      midpoint , default: 0.5
          The new center of the colormap. Defaults to
          0.5 (no shift). Should be between 0.0 and 1.0. In
          general, this should be  1 - vmax/(vmax + abs(vmin))
          For example if your data range from -15.0 to +5.0 and
          you want the center of the colormap at 0.0, `midpoint`
          should be set to  1 - 5/(5 + 15)) or 0.75
      stop , default: 1.0
          Offset from highest point in the colormap's range.
          Should be between0.0 and 1.0.
      name: str , default: shiftedcmap
      transparent_from : float , default: None
          The point between start and stop where the colors will start being transparent.
  
      """
      if transparent_from is None:
          transparent_from = stop
  
      cdict = {"red": [], "green": [], "blue": [], "alpha": []}
  
      # regular index to compute the colors
      reg_index = np.linspace(start, stop, 257)
  
      # shifted index to match the data
      shift_index = np.hstack(
          [
              np.linspace(0.0, midpoint, 128, endpoint=False),
              np.linspace(midpoint, 1.0, 129, endpoint=True),
          ]
      )
  
      for ri, si in zip(reg_index, shift_index):
          r, g, b, a = cmap(ri)
  
          cdict["red"].append((si, r, r))
          cdict["green"].append((si, g, g))
          cdict["blue"].append((si, b, b))
          if transparent_from / midpoint < si:
              cdict["alpha"].append((si, 0.3, 0.3))
          else:
              cdict["alpha"].append((si, a, a))
  
      newcmap = LinearSegmentedColormap(name, cdict)
      plt.register_cmap(cmap=newcmap)
  
      return newcmap
  
imports: import matplotlib.pyplot
  import numpy
  from matplotlib.cm import ScalarMappable
  from matplotlib.colors import LinearSegmentedColormap
label_desc: Use image node_id 2 for calling a global function with example usage: shifted_color_map(cmap, start, midpoint, stop, name, transparent_from) and returns: newcmap