How to make spaces between graphs in a subplot

4 views (last 30 days)
Linden
Linden on 23 Apr 2014
Answered: Gautam on 28 Aug 2024
I am using subplot to plot a number of graphs (see program below). The graphs in the subplot are too close to each other and the title of the graph (on top of each graph) is overlapped with the x axis of the above graph. Is there a way to increase the row space between the graphs? Many thanks in advance.
for i = 1:nvar subplot(8,5,i); plot(cell2mat(nonstnlist(2:end,i))); set(gca,'XLim',[1,obs]); title(nonstnlist(1,i),'interpreter','non'); saveas(gca,'nonstnlist.fig'); end

Answers (1)

Gautam
Gautam on 28 Aug 2024
Hello Linden,
I understand that you want to adjust the spacing between the individual graphs of a subplot. You can achieve this by setting the position of the graphs on the “Position” property of the axis handle of the graph.
The code below sets the position of the last graph in the subplot. In this, I have plotted a contour plot of the data received by the “peaks” function for all the plots
Z = peaks(100);
for i = 1:9
s = subplot(3,3,i);
contour3(Z);
title("Contours",'interpreter','non');
end
s.Position = [0.75 0.0500 0.2109 0.2157];
This gives the output as :
Hope this helps

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!