How to give one x and y axis label when using tiled layout('flow')?
180 ビュー (過去 30 日間)
古いコメントを表示
I am using tiled layout('flow') to plot a series of 20 plots on one figure. I want to have just one x and one y label for the entire figure, but when I try using the following code I get a figure that plots every subplot over each other.
figure()
t=tiledlayout('flow');
autoCorr = zeros(ceil(length(dataSource)),N);
lag = zeros(ceil(length(dataSource)),N);
for ii=1:N
[autoCorr(:,ii),lag(:,ii)] = autocorrelation(dataSource(:,ii));
nexttile(t)
plot(lag(:,ii),autoCorr(:,ii))
end
title(t,'title')
xlabel(t,'xlabel')
ylabel(t,'ylabel')
When I use this code the plot works fine but I'm not sure how to add the x and y axis labels.
autoCorr = zeros(ceil(length(dataSource)),N);
lag = zeros(ceil(length(dataSource)),N);
figure()
tiledlayout('flow')
for ii=1:N
[autoCorr(:,ii),lag(:,ii)] = autocorrelation(dataSource(:,ii));
nexttile
plot(lag(:,ii),autoCorr(:,ii))
% xlim([100,fmax])
end
0 件のコメント
採用された回答
Cris LaPierre
2022 年 10 月 4 日
Use the xlabel and ylabel functions with the first input being your tiled layout object. The code below is taken from this example.
t = tiledlayout(2,2,'TileSpacing','Compact');
% Tile 1
nexttile
plot(rand(1,20))
title('Sample 1')
% Tile 2
nexttile
plot(rand(1,20))
title('Sample 2')
% Tile 3
nexttile
plot(rand(1,20))
title('Sample 3')
% Tile 4
nexttile
plot(rand(1,20))
title(t,'Size vs. Distance')
xlabel(t,'Distance (mm)')
ylabel(t,'Size (mm)')
6 件のコメント
Cris LaPierre
2024 年 3 月 26 日
I don't know of a way to add a shared label to a subset of the plots. In this case, I suggest labeling each Y axis individually
Gorp Gorp
2024 年 8 月 9 日 10:12
編集済み: Gorp Gorp
2024 年 8 月 9 日 10:24
Hey there, you could do it with nested tiled layouts:
t0 = tiledlayout(1,2,'TileSpacing','tight');
%coloumn 1
t1 = tiledlayout(t0,3,1);
t1.Layout.Tile=1;
for i=1:3
nexttile(t1);
imagesc([]);
title(num2str(i))
end
title(t1,'Title','FontWeight','bold');
ylabel(t1,'Pixel','FontWeight','bold');
xlabel(t1,'Pixel','FontWeight','bold');
%coloumn 2
t2=tiledlayout(t0,3,1);
t2.Layout.Tile=2;
for i=1:3
nexttile(t2);
imagesc([]);
title(num2str(i))
end
title(t2,'Title','FontWeight','bold');
ylabel(t2,'Pixel','FontWeight','bold');
xlabel(t2,'Pixel','FontWeight','bold');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!