"text" handle, how do I grab all text and rotate it in a figure?

383 visualizaciones (últimos 30 días)
Hi,
I've created a figure and annotated it using "text(x,y,'sample)" code, and I've got about 8 instances of it on my figure. I want to rotate all of these by 90 degrees since they're starting to overlap as I increase the axis ranges.
I'm hoping there's a way to grab the text object handles and then I think there's a text property that I can use 'rotate',90 to flip them all sideways.
SO the main question is, if I only wrote:
text(x,y,'sample')
rather than
text_handle = text(x,y,'sample)
does anyone know a way of grabbing the text object handles so that I can rotate them, without having to delete them and then re-do them? (I've lost their original positions).
Thanks.

Respuesta aceptada

Youssef  Khmou
Youssef Khmou el 13 de Jun. de 2013
Michael, The default rotation in text is 0°.
The text properties can be adjusted as the following example :
plot(randn(100,1));
h=text(1,1,' My description');
set(h,'Rotation',90);
  3 comentarios
Youssef  Khmou
Youssef Khmou el 13 de Jun. de 2013
Editada: Youssef Khmou el 13 de Jun. de 2013
hi, you have two ways :
1) use the data cursor in the 'tools' option in your figure to find the coordinates of the text written .
2)Use the findobj function to locate your text and then process it :
Here is an example :
plot(randn(10,4));
text(1,1,'Random variables');
% here i have no structure for the text, i locate it using :
H=findobj(gca,'Type','text');
set(H,'Rotation',60); % tilt
Michael
Michael el 13 de Jun. de 2013
This looks perfect, thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by