How to put a title on a colorbar?
Afficher commentaires plus anciens
I have a 3D surface surf(X,Y,Z) viewed from view(0,90) with a colorbar which I want to put a title on. The help instructions talk about an lcolorbar, TitleString and ZlabelString but there's no example and I'm lost.
[X Y]=meshgrid(0:100,0:100);
Z=Y;
surf(X,Y,Z);
view(0,90);
hcb=colorbar;
?????? what next to put a title on the colorbar please ?????
Maybe something like set(get(hcb,'Title'),'cb title') but I wouldn't be asking if that worked ...
Thanks.
Réponse acceptée
Plus de réponses (2)
Mitsu
le 14 Juil 2020
Alternatively,
hcb=colorbar;
hcb.Title.String = "A Title";
Among the properties of "hcb" there is "Title", which is a Text data type that again contains properties regarding the content of the text (the "String"), formatting, location, etc.
Note the variable type of each part:
>> class(hcb)
ans =
'matlab.graphics.illustration.ColorBar'
>> class(hcb.Title)
ans =
'matlab.graphics.primitive.Text'
>> class(hcb.Title.String)
ans =
'char'
hcb=colorbar
title(hcb,'title')
1 commentaire
Adam Danz
le 21 Avr 2026
+1
This is the simplest solution
Catégories
En savoir plus sur Title dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!