有很多次要情节,每个次要情节都有自己的标题。如何为所有这些子图组添加标题? 我希望这个标题显示在顶部中心。
x = linspace(-5,5);
y1 = sin(x);
subplot(2,5,[1:2])
plot(x,y1)
title('y=sin(x)')
y2 = cos(x);
subplot(2,5,[3:4])
plot(x,y2)
title('y=cos(x)')
y3 = tan(x);
subplot(2,5,[5,10])
plot(x,y3)
title('y=tan(x)')
y4 = sin(2*x);
subplot(2,5,[6:7])
plot(x,y1)
title('y=sin(2x)')
y5 = cos(2*x);
subplot(2,5,[8:9])
plot(x,y2)
title('y=acos(2x)')
最佳答案
自 Matlab 2018b 起,新函数 sgtitle
向子图组添加标题,只需添加 sgtitle('Subplot Title');
。它不需要工具箱。
例如:
subplot(1,2,1)
plot(cos(0:40));
title('cos');
subplot(1,2,2)
plot(sin(0:40))
title('sin');
sgtitle('Trigo');
关于matlab - 子图组的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33593964/