code: def sample_colormap(cmap_name, n_samples):
      
      colors = []
      colormap = cm.cmap_d[cmap_name]
      for i in np.linspace(0, 1, n_samples):
          colors.append(colormap(i))
  
      return colors
docs: Sample a colormap from matplotlib