1

How to convert discrete colormap to contiguous one in matplotlib? I need something like this:

import matplotlib.colors as colors
cm_d = colormap = colors.ListedColormap(["#ffffff", "#ffcdcd", "#ff989b", "#ff6669", "#ff1818", "#d20000", "#a30002", "#720001", "#500002", "#670061", "#5e1a8b", "#3d0064", "#555555", "#343434", "#000000"])
cm_c = do_some_magic(cm_d)

Discrete colormap (cm_d): Discrete colormap

Contiguous colormap (cm_c): enter image description here

Aqua
  • 11
  • 5

1 Answers1

1

To obtain a continuous colormap you want to call this method: https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.LinearSegmentedColormap.html#matplotlib.colors.LinearSegmentedColormap.from_list

Static method; factory function for generating a smoothly-varying LinearSegmentedColormap.

J_H
  • 17,926
  • 4
  • 24
  • 44