How to add text or annotation in matlab subplots?
5 次查看(过去 30 天)
显示 更早的评论
I have 12 scatter subplots, each for a particular year. I want to add 'year' and 'R-square value' in each subplot.
I tried 'text' but it is misplacing it. How to get it done? Here is my code,
i=1;
a=5;
step=0;
for year=2002:2013
if mod(year,4)==0
jump=366;
else
jump=365;
end
subplot(4,3,i)
scatter(data_final(step+1:step+jump,11), data_final(step+1:step+jump,12),...
a, 'filled', 'MarkerEdgeColor','b',...
'MarkerFaceColor',[0 .7 .7],...
'LineWidth',0.5)
R=corrcoef(data_final(step+1:step+jump,11), data_final(step+1:step+jump,12));
R=R(1,2)
set(gca, 'FontName', 'Arial', 'FontSize', 12)
ylim=get(gca,'ylim');
xlim=get(gca,'xlim');
text(xlim(1),ylim(2), num2str(year));
xlabel('VAR_1')
ylabel('VAR_2')
grid on;
title(num2str(year));
i=i+1;
step=step+jump;
end
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!