How to add title to plot annotation
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am making a histogram plot to represent data but I am unable to add a title to my annotation textbox. I am able to add a title to my legend with the following code:
lgd1 = legend('Histogram','Mean of Percent Burial','Critical Percent Burial');
lgd_title1 = title(lgd1,'Legend');
This creates a very nice bolded title in the legend and break line between the title and the legend entries. However, similar syntax seems to not work with annotations:
annot1 = annotation('textbox',dim1,'String',str1,'FitBoxToText','on');
annot_title1 = title(annot1,'Results');
The code for the annotation works fine, but using the title function does not work with the following error message:
Unrecognized function or variable 'annot1'.
Is it is possible to include an annotation title similar to legend titles? Or some other work around for this issue.
4 commentaires
Scott MacKenzie
le 12 Mar 2022
Modifié(e) : Scott MacKenzie
le 12 Mar 2022
@the cyclist ah yes. Thanks for the clarification. The handle argument for the title function, if used, is a handle to an object capable of receiving a title. That might be an axis (my response) but it could also be a legend, and maybe some other types of objects. But, it cannot be an annotation, since annotations have no such property.
Réponses (1)
the cyclist
le 12 Mar 2022
The textbox annotation object does not have a title property, as far as I can tell.
The first work-around that springs to mind is to create a second textbox annotation for the title.
0 commentaires
Voir également
Catégories
En savoir plus sur Labels and Annotations 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!

