How to show a colorbar of a certain range?
Show older comments
Hello all and happy Friday!
Let's say I have an image with a colormap and corresponding colorbar
I = imread('cameraman.tif');
imshow(I);
colormap jet
colorbar
I want the colorbar to only show colors for a certain range of values:
range_care = [100 150]; %show colors for values 100:150
Any ideas?
Thanks, plzzzz rply qckly its urgenttt
had to :)
Accepted Answer
More Answers (4)
Sean de Wolski
on 16 Oct 2014
3 Comments
Image Analyst
on 16 Oct 2014
Is that the same as caxis([-2,2])?
Sean de Wolski
on 17 Oct 2014
Olesia Oh
on 26 May 2021
so so thanks)
cmap = colormap; %get current colormap
cmap=cmap([min max],:); % set your range here
colormap(cmap); % apply new colormap
colorbar();
Harsha Vardhan Rao Avunoori
on 15 Jul 2011
Okay I don't know whether this is the right one or not.
But I have tried this.
I = imread('cameraman.tif');
imshow(I,'DisplayRange',[100 150]);
colormap jet
colorbar
Hope this is what your looking for.
-Harsha
1 Comment
Sean de Wolski
on 15 Jul 2011
Simone Gastaldon
on 3 Nov 2020
0 votes
I have a related problem, I don't know if this is the appropriate place to ask.
I'm plotting multiple sublots (9x2). For each row, the first sublot has a certain colorbar range and the second one has another. Each time I start plotting a new row (say r), the second subplot of the previous row (r-1,2) changes colorbar. I tried freezeColors and related utilities, to no avail. Anyone has advices?
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!