Rotate annotation textbox

조회 수: 25 (최근 30일)
Pablo
Pablo 2012년 1월 13일
편집: the cyclist 2025년 7월 12일
Hi,
Is there any way to rotate an annotation textbox? I want to do something like:
h = annotation('textbox',[0.5 0.5 0.1 0.1],'String','my annotation');
set(h,'Rotate',90)
The problem is that 'Rotate' isn't an annotation textbox propertie
I tried with "text" function but doesn't help me too much (i need to place a "general ylabel" on a lot of figures with subplots (4x2)), and the text position change in every figure :(
Regards

채택된 답변

the cyclist
the cyclist 2012년 1월 13일
편집: the cyclist 2025년 7월 12일
UPDATE: There is now a way to do this directly with annotations. See Nina's answer below.
I don't know how to do it with an annotation, but here is a way to do it with the text() function, using the XLim and YLim properties of the plots (without needing to know the ranges of the x and y data beforehand):
figure
plot(1:10)
xlim=get(gca,'XLim');
ylim=get(gca,'YLim');
ht = text(0.5*xlim(1)+0.5*xlim(2),0.6*ylim(1)+0.4*ylim(2),'My text');
set(ht,'Rotation',45)
set(ht,'FontSize',18)
In the text command, make sure that the fractions add up to 1 for both the x and y positions, and then it is easy to steer the text to where you want it, and make it consistent across figures.
  댓글 수: 1
Pablo
Pablo 2012년 1월 13일
It works! =D
Thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Nina
Nina 2025년 7월 10일
편집: Nina 2025년 7월 10일
The textbox annotation now has (counterclockwise) rotation capabilities in degrees, for example:
x = linspace(0,1);
y = x;
plot(x,y)
h = annotation('textbox',[0.43 0.40 0.10 0.10],String="my annotation");
h.Rotation = 38;

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by