共8组数,每组数长度为12
横坐标:1-12个月
matlab版本:2023b
目标:8组数分为两组 分别画在两个子图里,但共用一个图例和标题
t = tiledlayout(1,2,'TileSpacing','Compact');
nexttile%移动到下一个瓦片位置
plot(1:12, [5Base'; Mo5'; Mo0'; Mo0']);
title('S5');
xlim([0, 13]);
xticks(1:12);
xlabel('Month');
ylabel('d')
nexttile
plot(1:12, [MBase'; M5'; M0'; M30']); % 绘制剩下的四条折线
title('S85')
ylabel('d')
xlim([0, 13]);
xticks(1:12);
xlabel('Month');
%通过将 t 传递给 title、xlabel 和 ylabel 函数,显示共享标题和轴标签。
title(t,'vs');
cb =legend('Base', '1', '2', '3'); % 在整个布局中添加图例
cb.Layout.Tile = 'south';%设置legend位置
cb.Orientation = 'horizontal';%设置legend里的元素横向排列
效果图: