小编Whi*_*d13的帖子

如何为子图提供一个共同的图例?

我正在尝试创建一个子图的图形.我不希望子图有传说,而是想要有一个整体传说.

我读到可以通过仅向最后一个子图添加图例并通过position特征legend或通过使用一个子图图形位置调整其在图中的位置(例如subplot(2,3,5.5)仅用于显示图例).我更喜欢第二种选择,虽然直到现在我还没有成功.有帮助吗?

这是我的代码:

SLS=figure();
hold on
subplot(3,2,1);
plot(t,u{1},t,u{2},t,u{3},t,u{4},t,u{5},t,u{6});
title('SLS Levels');
subplot(3,2,2);
plot(t,log_u{1},t,log_u{2},t,log_u{3},t,log_u{4},t,log_u{5},t,log_u{6});
title('SLS Logarithms');
subplot(3,2,3);
plot(t,I_u{1},t,I_u{2},t,I_u{3},t,I_u{4},t,I_u{5},t,I_u{6});
title('SLS Levels with Intercept');
subplot(3,2,4);
plot(t,log_I_u{1},t,log_I_u{2},t,log_I_u{3},t,log_I_u{4},t,log_I_u{5},t,log_I_u{6});
title('SLS Log. with Intercept');
subplot(3,2,5.5);
legend('GDP', 'C', 'I', 'G', 'Imp.', 'Exp.');
axis off
Run Code Online (Sandbox Code Playgroud)

matlab legend figure subplot matlab-figure

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

figure ×1

legend ×1

matlab ×1

matlab-figure ×1

subplot ×1