How to set the unequal interval colorbar for colormap!

33 次查看(过去 30 天)
Hello, how to set the colorbar as the picture shows?
The colorbar is not the equal interval!
Thanks!
QQ截图20190528140347.jpg

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2019-5-28
The QD-way I'd try first would be to make up a suitable transform of the data to map from being linear between 25 and 25 to what is desired. Something like this:
y = 1:19; % This defines the output of the data-transform
x = [-25:5:-5,-4:4,5:5:25]; % this is the input
d = 3*peaks(123);
dtr = d;
dtr(:) = interp1(x,y,d(:),'pchip'); % here we transform the data - only for displaying...
subplot(1,2,1)
imagesc(d)
colorbar
subplot(1,2,2)
imagesc(dtr)
cblh = colorbar; % and here we have to pay the price of being cunning/lazy
set(cblh,'ytick',1:19) % and set ticks and ticklabels manually
set(cblh,'ytick',1:19,'yticklabel',num2str(x'))
HTH
  3 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2019-5-28
That mapping simply takes the values of my d and puts values between -25 and -20 to values between 1 and 2, values between -20 and -15 will end up between 2 and 3 in the output - and so on. Therefore values between 0 and 1 will end up between 9 and 10 in the output (10 and 11, somewhere in the middle) and will occupy the same fraction of the range of output data as values between -25 and -20. If you have a book on image processing at hand you could look up histogram equalization, this is the same idea.
ren ren
ren ren 2019-5-28
Great answer! Solve the problem perfect!
Thanks very much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by