# Use of tight_subplot for plotting graphs from table

조회 수: 2(최근 30일)
Annika Vollebregt 2021년 2월 5일
댓글: Srivardhan Gadila 2021년 2월 9일
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])

댓글을 달려면 로그인하십시오.

### 답변(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표시숨기기 이전 댓글 수: 1
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.

댓글을 달려면 로그인하십시오.

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by