code: def vals2bins(vals,res=100):
      
      # flatten if list of lists
      if any(isinstance(el, list) for el in vals):
          vals = list(itertools.chain(*vals))
      return list(np.digitize(vals, np.linspace(np.min(vals), np.max(vals)+1, res+1)) - 1)
docs: Maps values to bins
      Args:
      values (list or list of lists) - list of values to map to colors
      res (int) - resolution of the color map (default: 100)
      Returns:
      list of numbers representing bins