matlab - 子图组的标题

标签 matlab label title figure subplot

有很多次要情节,每个次要情节都有自己的标题。如何为所有这些子图组添加标题? 我希望这个标题显示在顶部中心。

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');

trigo

关于matlab - 子图组的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33593964/

相关文章:

linux - Ubuntu 16.10 上的 Matlab 外部编辑器

iphone - 如何手动调用UITableView的titleForHeaderInSection方法?

Matlab:如何根据其他列中的条目对特定范围内的值求和

matlab - 如何使用 Graph Cuts 分割灰度二维图像中的对象?

Android:如何将 Activity 标签居中

animation - 快速更改带有动画的字体/标签大小

image - 数学: Add text to imported image/graphic as a label

Matlab 查询 : How to align 'title' at the botton of the figure when plotting points

r - 如何让 R corrplot 标题位置正确?

c# - 如何设置包含 C# 文件、MySQL 和 MATLAB 文件的项目