How to delimit the number of decimal places in a colorbar?

31 visualizaciones (últimos 30 días)
In this case, for example:
contourf(peaks(60))
colormap cool
colorbar('location','southoutside')
i want 4 decimal places.
thnks in adv,

Respuesta aceptada

José-Luis
José-Luis el 18 de Ag. de 2012
Editada: José-Luis el 18 de Ag. de 2012
contourf(peaks(60))
colormap cool
h=colorbar('location','southoutside');
yt=get(h,'XTick');
set(h,'XTickLabel',sprintf('%2.4f|',yt));
Cheers!
  2 comentarios
Matt Fig
Matt Fig el 18 de Ag. de 2012
Nice, Jose! I always seem to forget about the | option with these things.

Iniciar sesión para comentar.

Más respuestas (2)

Matt Fig
Matt Fig el 18 de Ag. de 2012
Editada: Matt Fig el 18 de Ag. de 2012
Here is an example of how to do it.
contourf(peaks(60))
colormap cool
C = colorbar('location','southoutside'); % Get the handle.
% Now use the current xtick to make an xticklabel we like.
L=cellfun(@(x)sprintf('%.4f',x),num2cell(get(C,'xtick')),'Un',0);
set(C,'xticklabel',L)

Artur M. G. Lourenço
Artur M. G. Lourenço el 18 de Ag. de 2012
OWW, thank you guys!!!

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by