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

392 views (last 30 days)
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.

Accepted Answer

Youssef  Khmou
Youssef Khmou on 13 Jun 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 Comments
Youssef  Khmou
Youssef Khmou on 13 Jun 2013
Edited: Youssef Khmou on 13 Jun 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

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!