Did you know that you can customize the direction of text in MATLAB plots? There are times when such annotations work better
than if they were purely horizontal or vertical.
Let's label these few other peaks in a similar manner to the first one.
nearMaxYears = year(indssa(idxdistinct(2:end)))
ssaMax = spots(indssa(idxdistinct(2:end)))
hold on
plot(nearMaxYears, ssaMax, 'mo')
hold off
hn = text(nearMaxYears, ssaMax,[' high sunspot activity '],...'HorizontalAlignment','Right','Rotation',25);
set(ht,'Rotation',0)
Just for fun now, let's write a phrase around a circle of radius 1.
clf, box on
phrase = 'ring around the collar ';
num = length(phrase)
angles = 0:(360/num):359;
x = cos(angles*pi/180);
y = sin(angles*pi/180);
for ind = 1:length(phrase)
text(x(ind),y(ind),phrase(ind),'Rotation',angles(ind),...'HorizontalAlignment','center')
end
axis equal, axis([-1.1 1.1 -1.1 1.1])
num =
23
References
There is a whole lot more you can do with text annotation in MATLAB. Here are some references for the language aspects of working with text.
Though I don't want to turn this blog into one chiefly about graphics, I think I can cover some aspects here and still talk
about it in terms of the language. Any suggestions? Please post them here.
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.