필터 지우기
필터 지우기

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

조회 수: 48 (최근 30일)
Artur M. G. Lourenço
Artur M. G. Lourenço 2012년 8월 18일
댓글: Luis Botton 2018년 6월 26일
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일
Nice, Jose! I always seem to forget about the | option with these things.

댓글을 달려면 로그인하십시오.

추가 답변 (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
Artur M. G. Lourenço 2012년 8월 18일
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