How to move the colorbar label to top position of the bar?
177 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kalasagarreddi Kottakota
le 7 Août 2023
Modifié(e) : Dyuman Joshi
le 7 Août 2023
I need to change the colorbar label to the position showed in the attached image.
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
clims = [4 18];
imagesc(C,clims)
e=colorbar;
e.Label.String = 'amp';
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1452362/image.png)
0 commentaires
Réponse acceptée
Dyuman Joshi
le 7 Août 2023
Modifié(e) : Dyuman Joshi
le 7 Août 2023
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
clims = [4 18];
imagesc(C,clims)
e=colorbar;
e.Label.String = 'amp';
%Adjust the position of the label
e.Label.VerticalAlignment = 'middle';
%The positioning, in the default unit, of the text label
%is corresponding to the values of colorbar
%x value is Middle of the colorbar i.e. 0.5
%y value is slightly above the top limit of colorbar
e.Label.Position = [0.5 clims(2)+0.75];
Edit - If you want to make the text horizontally aligned, change the rotation to 0 by using the command below
e.Label.Rotation = 0;
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Red 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!