New colormaps : Inferno, Viridis, ...

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!

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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?

The LinearSegmentedColormap has quite a bit of machinery that is not
needed when colormaps can be supplied as a long list of smoothly varying
colors, for which ListedColormap is a natural fit. What we missed,
however, is a bug that you have found: the _resample() method of
ListedColormap is not doing what it should do.

Then, is there a way I could get a LinearSegmentedColormap from Inferno,
Viridis, etc... ? This is really what I want.

Fixing _resample() would solve your problem; the only difference in
usage between LinearSegmentedColormap and ListedColormap is in the
inputs used to initialize them. Once properly initialized, the color
lookup mechanism is the same for both because it is inherited from the
common base class.

Would you mind opening an issue on github for this?

Eric

···

On 2015/12/11 7:29 AM, Aston630 wrote:

Thanks a lot for your time and considering this issue!

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

Thank you very much for your answer, I really appreciate your help!

I would not mind opening an issue on github, but I never did it and I am not
sure how to go forward with the procedure...could somebody else do it for
me? I am sorry about that.

Thanks again for everything!

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530p46558.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

It is very easy to create a new issue. Go to this page and click on the
"New Issue" button. If you don't have a github account already, then you
will need to create one, but the website will take you through that process
when you click on that button, I think.

Cheers!
Ben Root

···

On Sun, Dec 27, 2015 at 8:46 AM, Aston630 <gael.grissonnanche1 at gmail.com> wrote:

Thank you very much for your answer, I really appreciate your help!

I would not mind opening an issue on github, but I never did it and I am
not
sure how to go forward with the procedure...could somebody else do it for
me? I am sorry about that.

Thanks again for everything!

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530p46558.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160105/171e7f18/attachment.html&gt;

* Where "this page" means Issues · matplotlib/matplotlib · GitHub =)

···

On Wed, Jan 6, 2016 at 2:37 AM Benjamin Root <ben.v.root at gmail.com> wrote:

It is very easy to create a new issue. Go to this page and click on the
"New Issue" button. If you don't have a github account already, then you
will need to create one, but the website will take you through that process
when you click on that button, I think.

Cheers!
Ben Root

On Sun, Dec 27, 2015 at 8:46 AM, Aston630 <gael.grissonnanche1 at gmail.com> > wrote:

Thank you very much for your answer, I really appreciate your help!

I would not mind opening an issue on github, but I never did it and I am
not
sure how to go forward with the procedure...could somebody else do it for
me? I am sorry about that.

Thanks again for everything!

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530p46558.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160106/9ea14627/attachment.html&gt;

D'oh! I even still had that link in my clipboard!

···

On Jan 5, 2016 8:23 PM, "Juan Nunez-Iglesias" <jni.soma at gmail.com> wrote:

* Where "this page" means Issues · matplotlib/matplotlib · GitHub
=)

On Wed, Jan 6, 2016 at 2:37 AM Benjamin Root <ben.v.root at gmail.com> wrote:

It is very easy to create a new issue. Go to this page and click on the
"New Issue" button. If you don't have a github account already, then you
will need to create one, but the website will take you through that process
when you click on that button, I think.

Cheers!
Ben Root

On Sun, Dec 27, 2015 at 8:46 AM, Aston630 <gael.grissonnanche1 at gmail.com> >> wrote:

Thank you very much for your answer, I really appreciate your help!

I would not mind opening an issue on github, but I never did it and I am
not
sure how to go forward with the procedure...could somebody else do it for
me? I am sorry about that.

Thanks again for everything!

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/New-colormaps-Inferno-Viridis-tp46530p46558.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160105/67110d6c/attachment.html&gt;