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)]);

추가 답변 (0개)

카테고리

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