How do I create a logarithmic scale colormap or colorbar?
이전 댓글 표시
I need to color 'surf' plots on a log scale and subsequently displace the log-based colorbar.
채택된 답변
추가 답변 (2개)
lvn
2023년 11월 9일
편집: Rena Berman
2023년 11월 22일
set(gca,'ColorScale','log')
댓글 수: 4
jonas
2018년 5월 21일
I'm pretty sure it was introduced in 2018a
Walter Roberson
2018년 8월 22일
Another approach for R2018a is:
cb = colorbar();
cb.Ruler.Scale = 'log';
cb.Ruler.MinorTick = 'on';
In theory this should also work in R2017b (and perhaps other releases), but in R2017b you will get an warning message,
Warning: Error updating ColorBar.
DataSpace or ColorSpace transform method failed
Walter Roberson
2020년 3월 31일
You can tell by the wording of the official answer that it was written for an older version of MATLAB.
Pat Williamson
2023년 5월 11일
편집: Walter Roberson
2023년 9월 5일
Hi Kristoffer Walker,
If you still need assistance with this issue, please create a MathWorks Technical Support Case. We would be happy to help you out.
Berthold Reisz
2019년 3월 15일
Try the following:
% let A be your data
A = 100*rand(100,100);
% plot log10 of A
pcolor(log10(A))
% get the minimum and maximum value of A
c1 = min(min(A));
c2 = max(max(A));
% set limits for the caxis
caxis([log10(c1) log10(c2)]);
% preallocate Ticks and TickLabels
num_of_ticks = 5;
Ticks = zeros(1,num_of_ticks);
TickLabels = zeros(1,num_of_ticks);
% distribute Ticks and TickLabels
for n = 1:1:num_of_ticks
Ticks(n) = log10(round(c2)/num_of_ticks*n);
TickLabels(n) = round(c2)/num_of_ticks*n;
end
% set Ticks and TickLabels
colorbar('Ticks',Ticks,'TickLabels',TickLabels)
카테고리
도움말 센터 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
