How to limit the colorbar range in using image function ??
36 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hello
I want to limit the colorbar range in using image function.
caxis([0 10]) comment can limit the range other function (i.e mesh), but can not work at image function.
how I limit the colorbar range??
thank you.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 30 Jun. 2021
caxis works fine with image()
figure
img = imread('cameraman.tif');
image(img)
colormap(hsv)
caxis([0 10])
colorbar
But remember that colorbar() does not reflect RGB objects
figure
img = imread('flamingos.jpg');
image(img)
colormap(hsv)
caxis([0 10])
colorbar
3 Kommentare
Walter Roberson
am 30 Jun. 2021
I see what you mean; caxis() is not changing the colorbar() limit
Fortunately you can pass in the limits in the colorbar() call.
[R, TH] = ndgrid(complex(1:11, -5:5), linspace(0,2*pi));
[X, Y] = pol2cart(TH, R);
Z = X.^2 - 3.*X.*Y + Y;
figure
surf(real(X), real(Y), real(Z), 'edgecolor', 'none')
figure
surf(imag(X), imag(Y), imag(Z), 'edgecolor', 'none')
figure
RZ = real(Z);
image(RZ)
cb = colorbar('limits', [-50 50]);
cb
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colorbar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!