Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab - setting up the scale in imagesc automatically

Tags:

image

matlab

I am trying to compare plots that I create by matlab imagesc, and hence need the color limits to be identical to the higher one.

I tried digging, but couldn't find an easy way to do that, or at least figure out the limits without opening the colormap editor.

Thanks much for any help!

Alon.

like image 207
AlonGoren Avatar asked Dec 08 '25 06:12

AlonGoren


1 Answers

You can set the limits of the color-scale using caxis

img1 = randn(100);
img2 = rand(100);

%# find global min/max
clim(1) = min(min(img1(:)),min(img2(:)));
clim(2) = max(max(img1(:)),max(img2(:)));

figure
ah1 = axes;
imagesc(img1)
caxis(ah1,clim)

%# show the other figure set the same limits to colormap
figure
ah2 = axes
imagesc(img2);
caxis(ah2,clim)
like image 176
Jonas Avatar answered Dec 11 '25 00:12

Jonas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!