Use of tight_subplot for plotting graphs from table
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I am a new learner of Matlab. I am using the subplot function to create multiple graphs (data from table) on one page. Since the margin are really big, I tried to implement the tight_subplot function, but I am running into a problem there.
My graphs are all plotted on 1 square, while empty graphs are displayed in the other three squares. Certainly, I am doing something wrong with the implementation of the tight_subplot function. Can someone help me? How can I tell Matlab that I want to apply tight_subplot to these 4 graphs?
first = dataset1 (6:23,:);
second = dataset1(24:42,:);
%%
[ha, pos] = tight_subplot(2, 2, 0.01, 0.01, 0.01)
x1 = first{:,102};
y1 = first{:,101};
subplot(10,6,1)
plot(x1,y1,'.-')
xlim([0 30])
ylabel("depth(cm)")
set (gca,'YDir','reverse')
title ('Corg (umol/g)')
pbaspect([1 2 1])
%%
x2 = first{:,22};
y2 = first{:,5};
subplot(10,6,2)
plot(x2,y2,'.-')
xlim([0 100])
set (gca,'YDir','reverse')
title ('Mn/Al (umol/g/wt%)')
pbaspect([1 2 1])
%%
x1b = second{:,102};
y1b = second{:,101};
subplot(10,6,7)
plot(x1b,y1b,'.-')
xlim([0 30])
ylabel("depth(cm)")
set (gca,'YDir','reverse')
pbaspect([1 2 1])
%%
x2b = second{:,22};
y2b = second{:,5};
subplot(10,6,8)
plot(x2b,y2b,'.-')
xlim([0 100])
set (gca,'YDir','reverse')
pbaspect([1 2 1])
0 Kommentare
Antworten (1)
Srivardhan Gadila
am 8 Feb. 2021
You can make use of TileSpacing Name-Value pair argument of tiledlayout. For more information you can refer to the hyperlinks and the following answer How to remove labels and grey space between subplots so that the subplots fill-up the entire figure.
2 Kommentare
Srivardhan Gadila
am 9 Feb. 2021
You can try executing the code from the referred MATLAB Answer above and see if it works as per your requirements.
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!