Spaceplots
Customize spaces between subplots in a figure
Author: Aditya

With v3.0, the earlier errors with legend and colorbars will now disappear!

17 Apr 2012

tight subplot
Fills the figure with axes subplots with easily adjustable margins and gaps between the axes.
Author: Pekka Kumpulainen

Hey,

Great function. Pity I came across it after I spent much of my time writing a similar function. As some people have said above, I wanted the function to work with multiple rows/columns spanning subplots. So I included that capability in the following function:

Spaceplots
Customize spaces between subplots in a figure
Author: Aditya

Hi Ralph,

Thanks for your feedback. I've updated the file with your suggestion and a couple of minor fixes.

I'm curious though, I've never had the problem you mentioned during my use. Comparing floats is bound to crash when you are comparing values of two variables that have been computed. But in this case essentially it is the exact same value assigned to the variables being compared, in which case there should be no problem.

However, like Hakon, I wanted to be able to use it on the merged plots. Also, I wanted to use the standard Matlab functions as much as possible to draw the plot before applying the resize.

So I wrote a little function:
http://www.mathworks.in/matlabcentral/fileexchange/35464-spaceplots

Hello! I would like to report a bug. In some case of figure deleting one get the error in function "removeAxesFromGrid(p,ax)" at command "rmappdata(p,'SubplotListeners')" -- this field does not exist. So, I propose to add a verification via "isappdata".

31 May 2013

Spaceplots
Customize spaces between subplots in a figure
Author: Aditya

For those who get the error
"Attempted to access GridLeft...index must be a positive integer or logical", you need to call spaceplots BEFORE changing axis ticks, or adding colorbar, etc... For example for the colorbar, try

Hello! I would like to report a bug. In some case of figure deleting one get the error in function "removeAxesFromGrid(p,ax)" at command "rmappdata(p,'SubplotListeners')" -- this field does not exist. So, I propose to add a verification via "isappdata".

5

31 May 2013

Spaceplots
Customize spaces between subplots in a figure

For those who get the error
"Attempted to access GridLeft...index must be a positive integer or logical", you need to call spaceplots BEFORE changing axis ticks, or adding colorbar, etc... For example for the colorbar, try
a1=subplot(2,1,1);scatter(rand(10,1),rand(10,1),5,rand(10,1))
a2=subplot(2,1,2); scatter(rand(10,1),rand(10,1),5,rand(10,1))
spaceplots
axes(a1); colorbar
axes(a2); colorbar

5

08 Jan 2013

Spaceplots
Customize spaces between subplots in a figure

When I use image or imagesc with a colour bar I get the following error:
Attempted to access GridLeft(0,4); index must be a positive integer or logical.
Error in spaceplots (line 228)
axLeft = GridLeft(r0,c0) + InsetLeft(r0,c0);
Try this code as an example:
figure;
for i = 1:8
subplot(2, 4, i);
imagesc(rand(100, 10));
colorbar;
end;
spaceplots([.01 .01 .01 .01], [.02 .02]);

Comment only