How to set the unequal interval colorbar for colormap!
34 ビュー (過去 30 日間)
古いコメントを表示
Hello, how to set the colorbar as the picture shows?
The colorbar is not the equal interval!
Thanks!
0 件のコメント
採用された回答
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
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!