How to add text or annotation in matlab subplots?
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!