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

48 次查看(过去 30 天)
In this case, for example:
contourf(peaks(60))
colormap cool
colorbar('location','southoutside')
i want 4 decimal places.
thnks in adv,

采纳的回答

José-Luis
José-Luis 2012-8-18
编辑:José-Luis 2012-8-18
contourf(peaks(60))
colormap cool
h=colorbar('location','southoutside');
yt=get(h,'XTick');
set(h,'XTickLabel',sprintf('%2.4f|',yt));
Cheers!

更多回答(2 个)

Matt Fig
Matt Fig 2012-8-18
编辑:Matt Fig 2012-8-18
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
OWW, thank you guys!!!

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by