[Matplotlib-users] Displaying raster colormap in a colorbar

Benjamin Root ben.v.root at gmail.com
Fri Aug 3 17:26:14 EDT 2018


Off the top of my head, I wonder if you can set the colormap after the fact
on the image and then create the colorbar. The colorbar is going to assume
whatever colormap was set, and the default is viridis. The problem is that
I don't think a colormap is set on the image when RGB data is passed in
(so, it'll be None), which then means that colorbar falls back on the
default from the system, which is usually viridis. If you call
`im.set_cmap('NameOfYourColormap')`, and then call colorbar(), I think
that'll work.

Ben Root


On Fri, Aug 3, 2018 at 5:14 PM, Bruno Pagani <bruno.pagani at astrophysics.eu>
wrote:

> Le 03/08/2018 à 23:09, Benjamin Root a écrit :
> > I think the issue is that the user is passing in an RGB array, but
> > wants a colormap that matches that array. That is a bit tricky. Do I
> > have my understanding correct?
> >
> > Ben
>
> Exactly what I understood too. So do you have a solution for this? I’ve
> stackoverflow’d that question a bit, nothing cames out.
>
> Bruno
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180803/3d2a638e/attachment.html>


More information about the Matplotlib-users mailing list