How to add title to plot annotation
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Scott MacKenzie
el 12 de Mzo. de 2022
Editada: Scott MacKenzie
el 12 de Mzo. de 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.
Respuestas (1)
the cyclist
el 12 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Labels and Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

