[Matplotlib-users] Displaying raster colormap in a colorbar
bruno.pagani at astrophysics.eu
Fri Aug 3 17:04:58 EDT 2018
Le 03/08/2018 à 22:43, Matthew Bradley a écrit :
> I have a raster that I want to add a colorbar to, and I've tried
> playing around with a few things, both giving the axes image a name
> and then calling it in the colorbar function i.e:
> cax = axes.imshow(raster_contrast*sorted_raster, aspect=aspect_ratio)
> cbar = fig.colorbar(cax, orientation='horizontal')
> and after the image is plotted like so:
> cax = ax.get_images()
> cbar = fig.colorbar(cax, orientation='horizontal', cax=ax)
> In either case it produces a PCyGY colormap
> instead of the diverging RGBlack color scheme. How can I replicate the
> correct color map in the color bar? Both of these methods appear to
> work for 2-D array.
> the sorted raster is an array of shape [861, 138, 3].
> Thanks in advance for any help!
I don’t really know how to get a colorbar for RGB(A) arrays, but you
need to add something I guess. You’re currently getting the default
colormap and associated colorbar.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users