I have a 'text' object on my plot, how can I make it vertical or rotated at any other angle?

112 次查看(过去 30 天)
Consider the following MATLAB code to create a plot with a 'text' object:
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y)
text(pi,0,'\leftarrow sin(\pi)')
Is there some way to make the text 'vertical' or rotated at any other angle, instead of 'horizontal'?

采纳的回答

MathWorks Support Team
Yes, you can do this by modifying the 'Rotation' property of the text object's handle.
Please take a look at the following MATLAB code for an illustrative example:
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y);
% create some text objects on the plot and get there 'handles'
t = text(pi,0,'\leftarrow sin(\pi)');
t1 = text(1,0,'text1');
t2 = text(2,0,'text2');
t3 = text(5,0,'text3');
% Specify rotation angles for the 'text' object handles
t.Rotation = 90;
t1.Rotation = 30;
t2.Rotation = 180;
t3.Rotation = 45;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by