How to put a title on a colorbar?
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (2)
Mitsu
il 14 Lug 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 Commento
Adam Danz
il 21 Apr 2026 alle 13:44
+1
This is the simplest solution
Categorie
Scopri di più su Title in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!