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

75 visualizaciones (últimos 30 días)
Darax
Darax el 2 de Feb. de 2016
Comentada: Darax el 2 de Feb. de 2016
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

Respuestas (1)

Daniel Armyr
Daniel Armyr el 2 de Feb. de 2016
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 comentario
Darax
Darax el 2 de Feb. de 2016
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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by