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
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
With the axis ticks disables (set(gca,'xtick',[],'ytick',[])) I receive an error in spaceplots 228: "Attempted to access GridLeft(0,12); index must be a positive integer or logical.". Does anyone know how to fix it? I want to have all the plots directly adjacent without any visible axis or ticks in between.
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]);
4
26 Dec 2012
Spaceplots
Customize spaces between subplots in a figure
With the axis ticks disables (set(gca,'xtick',[],'ytick',[])) I receive an error in spaceplots 228: "Attempted to access GridLeft(0,12); index must be a positive integer or logical.". Does anyone know how to fix it? I want to have all the plots directly adjacent without any visible axis or ticks in between.