Place text below patch object
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have plotted a triangle as a patch object on my figure.
I wish to add a text box uicontrol object just below it to add information. How can I determine the location of the triangle in the figure to use as a location for the text box ?
[MOVED from section for answers - Jan]
I wanted to have a non-default background colour which is an option for uicontrol / text but not text.
1 comentario
Jan
el 11 de Abr. de 2019
Why do you want an uicontrol text box and not a text() object, which uses the coordinates of the axes directly?
Respuesta aceptada
Jan
el 12 de Abr. de 2019
Editada: Jan
el 12 de Abr. de 2019
Of course text allows to set the background color:
axes
text(0.5, 0.5, 'Hello', ...
'Color', 'r', 'BackgroundColor', 'c')
Therefore I'm still convinced, that a text object is much easier.
2 comentarios
Jan
el 23 de Abr. de 2019
Thanks for your suggestion - the text object is indeed easier. However, the appearance of the text in my case is too large once the background color is set (the size / extent of the box is not accessible as a property other than by sizing the actual text). There is greater flexibility to control the obect when created as a uicontrol.
The application usinmg the above is a complex GUI with a mixture of axes, uicontrol, text and other objects. In general, I would wish to determine the location of any object in the GUI so that I can add further information in the appropriate location. Being able to ascertain a common location across all obects gives the flexibility needed.
Jan
el 23 de Abr. de 2019
"the size / extent of the box is not accessible as a property other than by sizing the actual text"
I cannot confirm this opinion. Use the property 'Margin' to control the space around the text within the text box. The text object has more flexibility than an uicontrol.
You mention, that you want to determine the location - but in which coordinate system? With text it is trivial to use the local coordinates of an axes object, with an annotation or an uicontrol you can use the pixel coordinates relative to the figure. You can determine the position on the screen or on multiple screens easily also. The relation between the axes and the figure coordinates can be determined by simple maths in the 2D case. With 3D axes the projection method matters.
Más respuestas (1)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps 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!