How to use subplot to keep the aspect ratios of the individual plots?

조회 수: 76 (최근 30일)
Darax
Darax 2016년 2월 2일
댓글: Darax 2016년 2월 2일
Hi all!
at the moment i have the following problem:
i use "plot" to get some nice plots of concentration-time profiles (x-axis: Time, y-axis: Concentration). Now i want to plot two x-y-plots side by side without loosing the look (ratio of x-axis to y-axis) of the original/individual plots? Can i do that with subplot? When i use subplot the first plot goes to subplot(1,2,1) and the second to subplot(1,2,2). The problem is, that the space for the x-axes is shrunken to half of the original size. So that the x-axes are much shorter than the y-axes.
Is it possible to plot the two x-y-plots side-by-side in a way that they look as if they were plotted "alone" using subplot?
I hope i could make my problem understandable :)
Thank you in advance! Darax

답변 (1개)

Daniel Armyr
Daniel Armyr 2016년 2월 2일
This function changes the aspect ratio of plots: http://se.mathworks.com/help/matlab/ref/pbaspect.html
There is even a specific example that looks exactly like what you are describing:
ax1 = subplot(2,1,1);
surf(peaks)
ax2 = subplot(2,1,2);
plot(peaks)
pbaspect(ax2,[2 1 1])
  댓글 수: 1
Darax
Darax 2016년 2월 2일
Thank you Daniel for your quick answer!
I found that example also... i tried i again... and yes this works now!
To not open another topic a quick question on the above example: when you change the aspect ratio of the first subplot like shown below,
ax1 = subplot(2,1,1); surf(peaks) pbaspect(ax1,[2 1 1])
ax2 = subplot(2,1,2); plot(peaks) pbaspect(ax2,[2 1 1])
what you get are two nice plots with the correct aspect ratios. But there is a lot of white space on the left and the right. I tried to cope with that using:
set(gca, 'LooseInset', [0,0,0,0]);
but that didn't work out. Do you have an idea how i can get rid of the white spaces?
Thank you very much again!
Darax

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

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by