Help using tiledlayout and nexttile functions

13 visualizzazioni (ultimi 30 giorni)
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).
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.

Risposta accettata

the cyclist
the cyclist il 8 Lug 2023
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 Commenti
Angel Lozada
Angel Lozada il 9 Lug 2023
Dear the cyclist.
Thanks for your support, I really appreciated all your suggestions.
The attached figure that show the "expected" plots, is just for reference; is the same kind of data but not the same data.
What I would like is the box size for each subplot could be looks like the "expected" one.
Is there a way to enlarge the high of each box size?
Regards
clear;
data = readmatrix('Data2');
n=200;
T = data(:,1);
% T = seconds(data(:,1));
%T.Format = 'hh:mm';
T3 = data(:,3);
m3 = movmean (T3,n);
T4 = data(:,4);
m4 = movmean (T4,n);
T5 = data(:,5);
m5 = movmean (T5,n);
T6 = data(:,6);
m6 = movmean (T6,n);
T7 = data(:,7);
m7 = movmean (T7,n);
T8 = data(:,8);
m8 = movmean (T8,n);
T9 = data(:,9);
m9 = movmean (T9,n);
T10 = data(:,10);
m10 = movmean (T10,n);
T11 = data(:,11);
m11 = movmean (T11,n);
T12 = data(:,12);
m12 = movmean (T12,n);
T13 = data(:,13);
m13 = movmean (T13,n);
T14 = data(:,14);
m14 = movmean (T14,n);
T15 = data(:,15);
m15 = movmean (T15,n);
T16 = data(:,16);
m16 = movmean (T16,n);
tiledlayout(7,2);
nexttile
plot (T,m3,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title ('\fontsize{6}Emitted Signal from NAA Station');
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m4,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NAA Station';
% ylabel ('Apmlitude');
% xlabel ('Samples');
nexttile
plot (T,m5,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NLK Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m6,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NLK Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
nexttile
plot (T,m7,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NDK Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m8,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NDK Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
nexttile
plot (T,m9,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NWC Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m10,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NWC Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
nexttile
plot (T,m11,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NPM Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m12,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NPM Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
nexttile
plot (T,m13,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NPM II Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m14,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NPM II Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
nexttile
plot (T,m15,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NAU Station';
% ylabel ('Phase');
% xlabel ('Samples');
nexttile
plot (T,m16,'-');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
title '\fontsize{6}Emitted Signal from NAu Station';
% ylabel ('Amplitude');
% xlabel ('Samples');
the cyclist
the cyclist il 10 Lug 2023
Modificato: the cyclist il 19 Lug 2023
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Exploration in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by