Colorbar with equal ticks between two power exponentials

7 vues (au cours des 30 derniers jours)
Mathan
Mathan le 13 Avr 2022
Commenté : Mathieu NOE le 14 Avr 2022
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

Réponse acceptée

Mathieu NOE
Mathieu NOE le 13 Avr 2022
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 commentaires
Mathan
Mathan le 13 Avr 2022
Thank you - it works!
Mathieu NOE
Mathieu NOE le 14 Avr 2022
My pleasure !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by