Place text below patch object

10 visualizaciones (últimos 30 días)
Rob L
Rob L el 11 de Abr. de 2019
Respondida: Rob L el 23 de Abr. de 2019
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
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?

Iniciar sesión para comentar.

Respuesta aceptada

Jan
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
Jan el 23 de Abr. de 2019
[MOVED from section for answers] Rob L wrote:
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
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.
Maybe the functions getpixelposition (link) and setpixelposition (link) will help you.

Iniciar sesión para comentar.

Más respuestas (1)

Rob L
Rob L el 23 de Abr. de 2019
The functionality I need is indeed what is offered by the two linked functions.
Whilst the specific example may have been better served by a text object with the suggested properties, these functions seem to allow greater flexibility for a GUI contating axes, patch object and uicontrols.
Many thanks.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by