How to reduce horizontal distance between plots on 2x2 plot figure?

1 visualizzazione (ultimi 30 giorni)
I used subplot to create a 2x2 figure grid and then stacked the 2 pairs vertically because each pair uses the same x-axis. The figures will included in a publication so I need to get them to fit within the margins of a word document without sacrificing their resolution. The summary of the present code I am using now is given below:
h1 = subplot(2,2,1)
h2 = subplot(2,2,3)
p1 = get(h1,'Position');
p2 = get(h2,'Position');
p1(2) = p2(2) + p2(4);
h3 = subplot(2,2,2)
h4 = subplot(2,2,3)
p3 = get(h3,'Position');
p4 = get(h4,'Position');
p3(2) = p4(2) + p4(4);
I have also used the position vectors of the plot objects to close the vertical distance between plots using something like:
p1 = get(h1,'Position');
p2 = get(h2,'Position');
p2(2) = p2(2)*1.35;
p2(3) = p1(3);
Can something similar be done with the position vectors to close the horizontal distance between the plots even if though the vertical position has already been modified? Figure is given below as well. Thanks.

Risposte (1)

Iddo Weiner
Iddo Weiner il 2 Dic 2016
Try the following idea (might help, depends on the exact requirements of the journal etc.) - instead of going
subplot(2,2,1) ... subplot(2,2,4)
try defining subplot(M,N,Xi) - where M,N are the dimensions of the plot (and I will suggest setting them to an integer larger than 2), and Xi is a vector defining the location of subplot i (in your case: i=1:4). Here's an example in which M=N=4 :
Now, you can play around with M and N (don't forget to adjust the range accordingly). This won't actually change the absolute dimensions of the whole figure but it will get rid of the horizontal space between the columns. Hope this helps

Community Treasure Hunt

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

Start Hunting!

Translated by