How do I reformat the colorbar values from scientific notation to standard notation?

24 ビュー (過去 30 日間)
I am trying to figure out how to edit the format of the labels on the colorbar. From the sample code:
clear all; close all; clc;
A = rand(100,100)./(1e2);
figure; imagesc(A); colormap jet; colorbar;
The figure's colorbar labels are 1 through 9 with a "x 10^-3" at the top. How do I format the labels such that they show .001, .002, ....., .009 ? I need this to be dynamic, i.e. the range may change w/ the data I am displaying, so I cannot hardcode in tick labels.
Any thoughts? Thank you in advance! Kristin

採用された回答

Walter Roberson
Walter Roberson 2013 年 12 月 16 日
There is no way to turn that off without setting the tick labels.
Each time you set a new data range, you can
set(Colormap_axis, 'YTickLabel', cellstr(str2num(reshape(get(Colormap_axis, 'YTick'),[],1),'%0.3f')) )
(adjust the %0.3f as appropriate
  2 件のコメント
Kristin Busa
Kristin Busa 2013 年 12 月 16 日
Thanks, Walter. For future users, I think the str2num should instead be num2str, but with this adjustment it seems to work. Thanks!
Walter Roberson
Walter Roberson 2013 年 12 月 16 日
Sorry yes, num2str().

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by