Hi! I am working on creating a GUI using GUIDE, and I would like to rotate several of my GUI components (e.g. static text, sliders). In the Matlab documentation, it says that there is supposed to be a field named Rotate within each object's Property Inspector, which would easily allow the rotation of each object.
My problem: the Rotate field does *not* appear in any of the objects' Property Editors. I have made sure that I'm looking at the full list of properties. There doesn't seem to be any other way to manipulate these objects (e.g., no Rotate Object option anywhere in the drop-down menus).
Any suggestions about how I can rotate my GUI components? Thanks!
"Kathleen " <quisquiliae2@hotmail.com> wrote in message <f854tv$rst$1@fred.mathworks.com>...
> Anyone have input on this question? I'm hoping that someone has seen and solved this simple but annoying problem before. Thanks!
I beleive that rotate is a function, not a property?
Use rotate(handle.object, [1 0 0], angle)
so, [1 0 0] is simply which axis to rotate around.. x-axis in this case.. angle is the degrees (90, 180 etc)
and, within the object's Create Function callback,
rotate(hObject, [1 0 0], 90);
All of these calls produce error messages, and don't rotate the object. How should I refer to my Static Text object YAxisLabel to allow rotate() to recognize it? Thanks!
This is still not working; for each of the following
statements, I get the error message shown:
rotate(handles.YAxisLabel, [1 0 0], 90);
error: ??? Error: H must contain axes children only.
rotate(YAxisLabel, [1 0 0], 90);
error: ??? Undefined function or variable 'YAxisLabel'.
within the object's Create Function callback,
rotate(hObject, [1 0 0], 90);
error:??? H must contain axes children only.
The first argument of rotate( ) is supposed to be
a "graphics object". How can I refer to my static text
object in order to rotate it? Thanks for your input!
Kathleen
plot([0,1],[0,1]);
xh=xlabel('foo','rotation',30);
% note: this <rotation> is probably what you're looking for
% anyhow
rotax=[0,0,1];
rotor=[.5,0,0];
for i=1:360
rotate(xh,rotax,i,rotor);
pause(.01);
rotate(xh,rotax,-i,rotor);
end
Kathleen,
If you need to rotate text annotation objects, you should
be able to do it with 'Rotate' property of text. I dont know
how you could not find that property in the property editor
if you are indeed using 'text' object. Probably you are
using text box, by selecting 'Text box' from the insert menu.
Try this. When you have your figure visible, type
p = text(X,Y,'YourString');% here X, Y should be position
vector. This returns the text object's handle in p.
Now you can use rotate property on p, like this -
set(p,'Rotate',90);
Check for the properties of text in doc text.
Hope this helps.
"Kathleen " <quisquiliae2@hotmail.com> wrote in message
<f97bnq$aek$1@fred.mathworks.com>...
> This is still not working; for each of the following
> statements, I get the error message shown:
>
> rotate(handles.YAxisLabel, [1 0 0], 90);
> error: ??? Error: H must contain axes children only.
>
>
> rotate(YAxisLabel, [1 0 0], 90);
> error: ??? Undefined function or variable 'YAxisLabel'.
>
>
> within the object's Create Function callback,
> rotate(hObject, [1 0 0], 90);
> error:??? H must contain axes children only.
>
>
> The first argument of rotate( ) is supposed to be
> a "graphics object". How can I refer to my static text
> object in order to rotate it? Thanks for your input!
> Kathleen
>
>
>
Thanks for your reply, us. From the loop you provided, it
looks like your code rotates the object *within* the plot;
All I need to do is to display a static Y axis label that
never changes -- it needs to be located *outside* the
axes. Right now, this label ("Y (meters)") is horizontal,
and I simply need it to be vertical. This should be very
simple, but again, the supposed Rotate field within this
static text object's Property Editor doesn't exist.
Preferably, I would set its vertical orientation when my m-
file first starts executing, and then never have to touch
it again. Any simple way to do this? Thanks! Kathleen
Thanks for your response, John. When I tried your
suggested code, I get the error:
??? There is no 'Rotate' property in the 'text' class.
I'm not sure if your code would allow me to place my axis
label *outside* of my axes; I know that I have tried
simply using the ylabel() function, but this doesn't
display any label.
From the Help pages,
You can rotate axis labels using the Property Editor:
1. Start plot editing mode by selecting Edit Plot from
the figure Tools menu.
2. Display the Property Editor by selecting (left-
clicking) the axis label you want to rotate. Right-click
over the selected text, then choose Properties from the
context menu.
3. Click the More Properties button to display the
Property Inspector.
4. Select the Rotation property text field. A value of 0
degrees orients the label in the horizontal position.
5. With the left mouse button down on the selected
label, drag the text to the desired location and release.
In my case, for Step (1) my Tools menu doesn't give me
an Edit Plot choice, and when I display the Property
Editor, there is no Rotation field... Do you think that
this is a bug within my version of Matlab/GUIDE?
Sorry Kathleen,
I meant to write 'Rotation' and not 'Rotate' . So here is
what I just tried and it worked.
Simple type the below lines on your matlab prompt and check
if it works. If this simple example does not work, then I
think you can assume there is something wrong with your
matlab installation.
figure;
yl = ylabel('My Y label');
set(yl,'Rotation',0); this sets a ylabel horizontally aligned.
----- also try the below on the same figure
tobj = text('String',
'mytextobj','Units','pixels','Position',[20 20]);
This will draw a text object inside the axes. You can rotate
this by -
set(tobj,'Rotation',90);
To put this outside the axes, you can give negative values
to the position x,y co-ordinates.
set(tobj,'Position', [-30,20]) % this sets the label outside
west.
Try these.
"Kathleen " <quisquiliae2@hotmail.com> wrote in message
<f97fm3$8v0$1@fred.mathworks.com>...
> Thanks for your response, John. When I tried your
> suggested code, I get the error:
>
> ??? There is no 'Rotate' property in the 'text' class.
>
> I'm not sure if your code would allow me to place my axis
> label *outside* of my axes; I know that I have tried
> simply using the ylabel() function, but this doesn't
> display any label.
>
>
> From the Help pages,
>
> You can rotate axis labels using the Property Editor:
>
> 1. Start plot editing mode by selecting Edit Plot from
> the figure Tools menu.
>
> 2. Display the Property Editor by selecting (left-
> clicking) the axis label you want to rotate. Right-click
> over the selected text, then choose Properties from the
> context menu.
>
> 3. Click the More Properties button to display the
> Property Inspector.
>
> 4. Select the Rotation property text field. A value of 0
> degrees orients the label in the horizontal position.
>
> 5. With the left mouse button down on the selected
> label, drag the text to the desired location and release.
>
>
> In my case, for Step (1) my Tools menu doesn't give me
> an Edit Plot choice, and when I display the Property
> Editor, there is no Rotation field... Do you think that
> this is a bug within my version of Matlab/GUIDE?
>
> Any suggestions? Thanks!
>
>
>
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.