Use of tight_subplot for plotting graphs from table
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Srivardhan Gadila
2021-2-8
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 个评论
Srivardhan Gadila
2021-2-9
You can try executing the code from the referred MATLAB Answer above and see if it works as per your requirements.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!