matlab 中使用subplot时怎么用legend标注。我再一个图中画4个子图,想给他们共同标注应该怎么办

如题所述

第1个回答  推荐于2017-09-26
x=linspace(-2,2);
subplot 221
plot(sin(x),'r');
subplot 222
plot(sin(2*x),'g');
subplot 223
plot(sin(3*x),'b');
subplot 224
plot(sin(4*x),'k');
a=axes('visible','off');
hold on;
plot(0,0,'r');
plot(0,0,'g');
plot(0,0,'b');
plot(0,0,'k');
legend('sin x','sin 2x','sin 3x','sin 4x','location','north')追问

非常感谢!
但是这样画出来的图示会和第四个图重合,
如果我只画前三个图,然后把图示直接画在第四个图里,有没有办法?

追答

clear
clc

x=linspace(-2,2);
subplot 221
plot(x,sin(x),'r');
subplot 223
plot(x,sin(2*x),'g');
subplot 224
plot(x,sin(3*x),'b');
a=axes('visible','off');
hold on;
plot(0,0,'r');
plot(0,0,'g');
plot(0,0,'b');
legend('sin x','sin 2x','sin 3x','location','northeast')

本回答被提问者采纳
相似回答