【发布时间】:2020-04-05 16:08:49
【问题描述】:
我想要一个 7x3xi 的子图。使用以下代码后:
subplot(7,3,1)
figure(1);
hold on;
scatter(x,y,12,'k','filled');
[pp,s] = polyfit(x,y,1);
r_squared = 1 - s.normr^2 / norm(x-mean(y))^2;
str = {sprintf('y = %.2fx+%.2f',pp(1),pp(2)),sprintf('R^2 = %.2f',r_squared)};
annotation('textbox', [0.2, 0.75, .1, .1], 'String',str ,'FitBoxToText',...
'on','fontname','Cambria Math','HorizontalAlignment', 'center',...
'FontSize',8,'BackgroundColor', 'white');
xlabel('Observed precipitation (mm)','FontSize',8)
ylabel('Modeled precipitation (mm)','FontSize',8)
set(gca,'fontname','Times New Roman','FontSize',8) % Set it to times
box on;
grid on
hTrend = refline(pp(1), pp(2)); % Trend line
hrefline = refline([1 0]); % 45 degree refline
hrefline.Color = 'k';
axis normal
我看到了这个图: Image (对所有(7x3xi)重复此代码您可以看到非常糟糕的情况,并且在子图中我看到每个图的注释都消失了,只存在一个注释! 我想让我的支持类似于this。如果你能告诉我我有什么选择,我将不胜感激。最好的问候。
【问题讨论】:
-
为了方便贡献者,您可以添加一个所需变量的示例吗?比如
x和y。另外,你是否让i从 1 变为 21?由于您要绘制 7*3=21 个不同的图表,因此让i在该区间内工作很重要。 -
删除
figure(1)调用,它可能会搞砸。
标签: matlab matlab-figure