Colorbar with equal ticks between two power exponentials

7 ビュー (過去 30 日間)
Mathan
Mathan 2022 年 4 月 13 日
コメント済み: Mathieu NOE 2022 年 4 月 14 日
Hello,
I wanted to show a colorbar with values corresponding to equal step sizes of a certain number that is an exponent of 10 (for example if the number is 1e10 I would like to have a colorbar with ticks as 0.5e10, 1e10, 1.5e10, 2e10, 2.5e10 and 3e10).
Following is the code which I tried:
col = colorbar('XTickLabel', {'0', '0.5 x 10^{10}', '1 x 10^{10}', '1.5 x 10^{10}', '2 x 10^{10}','2.5 x 10^{10}', '3 x 10^{10}'}, 'XTick',linspace(log10(0e10),log10(3e10),7));
caxis([log10(0e10) log10(3e10)]);
but its not giving the ticks properly (attached is the plot which I get) and shows an error saying Value must be a numeric vector whose values increase.
Any advice on how to do this?
Thanks

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 4 月 13 日
hi
try this
figure
xt = linspace(0,log10(3e10),7);
col = colorbar('XTickLabel', {'0', '0.5 x 10^{10}', '1 x 10^{10}', '1.5 x 10^{10}', '2 x 10^{10}','2.5 x 10^{10}', '3 x 10^{10}'}, 'XTick',xt);
caxis([0 log10(3e10)]);
  2 件のコメント
Mathan
Mathan 2022 年 4 月 13 日
Thank you - it works!
Mathieu NOE
Mathieu NOE 2022 年 4 月 14 日
My pleasure !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by