Append/Alter string in Title
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to append additional text to the title of a plot. How do I "get" the title string in order to append the added text and replace the title with the modified string?
The help tells me how to replace the title, but I want to add, say, a date, or filename.
0 commentaires
Réponse acceptée
Wayne King
le 2 Mai 2012
plot(randn(100,1));
h = title('Test');
origtitle = get(h,'String');
set(h,'String',[origtitle ' 2'])
3 commentaires
Daniel Shub
le 3 Mai 2012
The terminology matters here: Figure->Axis->Object. The gca function returns the handle to the current Axis, not the Figure. The plot handle (presumably the handle returned by plot), is a handle to an Object.
The axis object has a child object called Title. You can get this with h = get(gca, 'Title'). The h from this command will be identical to the h in Wayne's answer.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!