Borrar filtros
Borrar filtros

Logarithmic scale for colorbar

103 visualizaciones (últimos 30 días)
Tom
Tom el 15 de Abr. de 2015
Comentada: Walter Roberson el 27 de Abr. de 2020
I sometimes require a plot which has a colorbar with a log scale. Previously I did this by setting the 'yscale' property of the underlying colorbar axes, but this no longer works with the new graphics system. Is there a workaround for the new system?

Respuesta aceptada

Jonathan Campelli
Jonathan Campelli el 15 de Abr. de 2015
Hello Tom,
My script plots sample data in logscale using "countourf", and both "YTick" and "YTickLabel" are set in "colorbar" on the last line:
Data=magic(100);
c=[1 10/3 10 100/3 100 1000/3 1000 10000/3 10000];
contourf(log(Data(:,:)),log(c));
colormap(bone); %Color palate named "bone"
caxis(log([c(1) c(length(c))]));
colorbar('FontSize',11,'YTick',log(c),'YTickLabel',c);
If this code does not meet your needs, let me know, and I will develop a more appropriate solution,
Best regards,
Jonathan Campelli
  2 comentarios
Troy Dion
Troy Dion el 3 de Ag. de 2017
Is there a way to make this work with scatter3?
Troy
Bo Wang
Bo Wang el 27 de Abr. de 2020
its a really nice answer to me , thanks !

Iniciar sesión para comentar.

Más respuestas (1)

Xiaolong
Xiaolong el 26 de Mzo. de 2020
set(gca,'colorscale','log')
  1 comentario
Walter Roberson
Walter Roberson el 27 de Abr. de 2020
Note: that was not available at the time the question was originally asked.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by