Help using tiledlayout and nexttile functions
12 次查看(过去 30 天)
显示 更早的评论
Hello.
I will really be appreciated if someone could help me with the follow inquiry:
I am trying to plot several subplots using tiledlayout and nexttile functions, however I am not getting the final plot as I would like (i.e., 8-by-2 tiled chart layout).
I had read https://www.mathworks.com/help/matlab/ref/tiledlayout.html and https://www.mathworks.com/help/matlab/ref/nexttile.html to learn more about these functions.
Any help is more than welcome.
Regards.
clear;
data = readmatrix('Data2');
T = data(:,1);
T = seconds(data(:,1));
T.Format = 'hh:mm';
T3 = data(:,3);
T4 = data(:,4);
T5 = data(:,5);
T6 = data(:,6);
T7 = data(:,7);
T8 = data(:,8);
T9 = data(:,9);
T10 = data(:,10);
T11 = data(:,11);
T12 = data(:,12);
T13 = data(:,13);
T14 = data(:,14);
T15 = data(:,15);
T16 = data(:,16);
tiledlayout(8,2);
nexttile
%figure; % Place "figure" in this section allow to plot this data in a separate window.
plot (T,T3,'x');
title 'Emitted Signal from NAA Station';
ylabel ('Phase');
xlabel ('Samples');
nexttile
%figure;
plot (T,T4,'x');
title 'Emitted Signal from NAA Station';
ylabel ('Apmlitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T5,'x');
title 'Emitted Signal from NLK Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T6,'x');
title 'Emitted Signal from NLK Station';
ylabel ('Amplitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T7,'x');
title 'Emitted Signal from NDK Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T8,'x');
title 'Emitted Signal from NDK Station';
ylabel ('Amplitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T9,'x');
title 'Emitted Signal from NWC Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T10,'x');
title 'Emitted Signal from NWC Station';
ylabel ('Amplitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T11,'x');
title 'Emitted Signal from NPM Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T12,'x');
title 'Emitted Signal from NPM Station';
ylabel ('Amplitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T13,'x');
title 'Emitted Signal from NPM II Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T14,'x');
title 'Emitted Signal from NPM II Station';
ylabel ('Amplitude');
xlabel ('Samples');
% figure;
nexttile
plot (T,T15,'x');
title 'Emitted Signal from NAU Station';
ylabel ('Phase');
xlabel ('Samples');
% figure;
nexttile
plot (T,T16,'x');
title 'Emitted Signal from NAu Station';
ylabel ('Amplitude');
xlabel ('Samples');
Regards.
0 个评论
采纳的回答
the cyclist
2023-7-8
It's unclear to me what you are expecting to get, but this code works exactly as I would expect.
You have defined an 8x2 grid of plots, but you have only actually called nexttile/plot 14 times. Therefore, you fill in the first 14 subplot slots (in the default order, which is row-major). The last 2 slots are empty.
4 个评论
the cyclist
2023-7-10
编辑:the cyclist
2023-7-19
It will help to use compact tile spacing and padding. Call tiledlayout with a handle:
t = tiledlayout(7,2);
and then run
t.TileSpacing = 'compact';
t.Padding = 'compact';
This will reduce the white space. Other than that, I'm not sure there is much more you can do to make the subplots larger.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!