
I have a 'text' object on my plot, how can I make it vertical or rotated at any other angle?
112 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2019-10-11
回答: MathWorks Support Team
2020-12-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
2019-10-11
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!