Skip to content

New colormaps : Inferno, Viridis, ... #5883

Closed
@ghost

Description

Hi,

I wanted to try today the new exciting colormaps that come with the 1.5.0 version of Matplotlib. I quickly discovered I could not use them the same as the previous colormaps. Indeed, in the past I used to do:

import matplotlib as mpl
cmap = mpl.cm.get_cmap("jet", nb_curves)

# where cmap is LinearSegmentedColormap and from there get the colors the following way in order to
# handle them the way I wanted for a set of curves or points or arrows etc... :
colors = cmap(np.arange(nb_curves))

Now with the new colormaps I do the same:

import matplotlib as mpl
cmap = mpl.cm.get_cmap("inferno", nb_curves)

where cmap is now a ListedColormap and I cannot do what I used to do before.

My first question would be : why this difference between old and new colormaps?
Then, is there a way I could get a LinearSegmentedColormap from Inferno, Viridis, etc... ? This is really what I want.

Thanks a lot for your time and considering this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions