How do I create a logarithmic scale colormap or colorbar?
Mostrar comentarios más antiguos
I need to color 'surf' plots on a log scale and subsequently displace the log-based colorbar.
Respuesta aceptada
Más respuestas (2)
lvn
el 9 de Nov. de 2023
Editada: Rena Berman
el 22 de Nov. de 2023
set(gca,'ColorScale','log')
4 comentarios
jonas
el 21 de Mayo de 2018
I'm pretty sure it was introduced in 2018a
Walter Roberson
el 22 de Ag. de 2018
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
el 31 de Mzo. de 2020
You can tell by the wording of the official answer that it was written for an older version of MATLAB.
Pat Williamson
el 11 de Mayo de 2023
Editada: Walter Roberson
el 5 de Sept. de 2023
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
el 15 de Mzo. de 2019
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)
Categorías
Más información sobre Axis Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
