I need to display a true color image, got with imread
and shown with imshow
, along with a (apparently) unrelated colorbar. I'm calling:
figure
imshow(my_image)
colorbar
colormap(cool(200));
caxis([0 15]);
Using a test image, it looks like this:
As you can see caxis
has no effect on the colorbar. Colorbar max value will stay 200
, which is the number of rows in my colormap. That's properly described by the documentation of caxis
, that says:
It does not affect surfaces, patches, or images with true color CData or with CDataMapping set to direct.
Is there any workaround?
I tried some weird stuff like subplotting the image on one side and the colorbar on the other (but I get a blank plot on this second side, and so much blank space out); I tried plotting zeros
, then colorbar
and caxis
, then replacing the zeros plot with imshow
(but colorbar gets refreshed accordingly). Any help?