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 :)

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 7월 15일

9 개 추천

Hi,
something like this:
h = colorbar;
set(h, 'ylim', [100 150])
Titus

댓글 수: 2

Titus Edelhofer
Titus Edelhofer 2011년 7월 15일
sorry, if it wasn't quick enough ;-)
Sean de Wolski
Sean de Wolski 2011년 7월 15일
That's it, and plenty quick - before third cup of coffee even...

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Sean de Wolski
Sean de Wolski 2014년 10월 16일

5 개 추천

In R2014b, this is now possible by setting the limits of the colorbar directly:
surf(peaks)
h = colorbar
h.Limits = [-2 2]

댓글 수: 3

Image Analyst
Image Analyst 2014년 10월 16일
Is that the same as caxis([-2,2])?
No. Caxis rescales the colormap so anything below caxis(1) is the minimal color and anything above caxis(2) is the top of the colormap
subplot(1,2,1)
surf(peaks)
h = colorbar;
h.Limits = [-2 2];
title('My original question from grad school')
subplot(1,2,2)
surf(peaks)
h = colorbar;
caxis([-2 2])
title('using caxis')
Olesia Oh
Olesia Oh 2021년 5월 26일
so so thanks)

댓글을 달려면 로그인하십시오.

Maohan Su
Maohan Su 2014년 1월 22일
편집: Maohan Su 2014년 1월 22일

1 개 추천

cmap = colormap; %get current colormap
cmap=cmap([min max],:); % set your range here
colormap(cmap); % apply new colormap
colorbar();
Harsha Vardhan Rao  Avunoori
Harsha Vardhan Rao Avunoori 2011년 7월 15일

0 개 추천

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

Sean de Wolski
Sean de Wolski 2011년 7월 15일
Thank you, but that's not what I'm looking for. That turns everything above 150 to red and everything below 100 to blue. I want the full range of the colormap displayed on the image; just the colorbar showing a fraction of the range.

댓글을 달려면 로그인하십시오.

Simone Gastaldon
Simone Gastaldon 2020년 11월 3일

0 개 추천

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?

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2011년 7월 15일

댓글:

2021년 5월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by