In matplotlib a color map isn't a list, but it contains the list of its colors as colormap.colors
. And the module matplotlib.colors
provides a function ListedColormap()
to generate a color map from a list. So you can reverse any color map by doing
colormap_r = ListedColormap(colormap.colors[::-1])