code: def vals2colors(vals,cmap='GnBu_d',res=100):
      
      # flatten if list of lists
      if any(isinstance(el, list) for el in vals):
          vals = list(itertools.chain(*vals))
  
      # get palette from seaborn
      palette = np.array(sns.color_palette(cmap, res))
      ranks = np.digitize(vals, np.linspace(np.min(vals), np.max(vals)+1, res+1)) - 1
      return [tuple(i) for i in palette[ranks, :]]
docs: Maps values to colors
      Args:
      values (list or list of lists) - list of values to map to colors
      cmap (str) - color map (default is 'husl')
      res (int) - resolution of the color map (default: 100)
      Returns:
      list of rgb tuples