code: def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
      """
      http://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib # noqa
      """
      import matplotlib.colors as colors
      import numpy as np
  
      new_cmap = colors.LinearSegmentedColormap.from_list(
          "trunc({n},{a:.2f},{b:.2f})".format(
              n=cmap.name, a=minval, b=maxval
          ),
          cmap(np.linspace(minval, maxval, n)),
      )
      return new_cmap
  
imports: from copy import copy
  from inspect import signature, _empty
  import re
  from collections.abc import Iterable
  from collections import defaultdict
  from itertools import product
  from six import string_types
label_desc: Use image node_id 14 for calling a global function with example usage: truncate_colormap(cmap, minval, maxval, n) and returns: new_cmap