The demo really shows what this can do. However, it doesn't show how to do it. I would probably increase my rating to a 5star if there were examples to go along with the function.

I'm in agreement with Toby. None of the functions on MATLAB central that address the spacing issue seem to handle spanning multiple columns/rows (tight_subplot.m,subplotSpacing.m or subaxis). The search continues.

17 Apr 2012

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

I second what Dan said. Spanning multiple columns/rows would be really useful. For example:
ha = tight_subplot(2,2,0.1,0.1,0.1)
axes(ha(1));plot(x1,y1);
axes(ha(2));plot(x2,y2);
axes(ha([3 4]))plot(x3,y3);

This doesn't work if you combine subplots - line 18 in the code catches it as an error. For example:
subplot(2,2,1);plot(x1,y1);
subplot(2,2,2);plot(x2,y2);
subplot(2,2,[3 4]);plot(x3,y3);
MATLAB returns:
Error using subplotSpacing (line 18)
dimensions of subplot do not match number of elements of h

Hello everybody,
Thank you all for finding and reporting the bugs. Unfortunately I've not made the transition to version 2014 yet. However I'll get this installed shortly.
Regarding the save-figure method: I've found that there is way which allows the figure to be saved and loaded keeping all methods and properties. I've started to work on this.
I'll probably upload a new - matlab 2014 compatible - version of subplot_grid during the xmas holidays.
Kind regards
Joris

Comment only

03 Dec 2014

subplot_grid
A subplot figure with a lot of fancy features

On the other hand, I've found a new issue. The use of the colorbar method doesn't seem to be working. Every time I try to use it I get the following error:
Error using colorbar (line 55)
Attempt to reference field of non-structure array.
Error in subplot_grid/colorbar (line 2181)
hcb = colorbar('peer',this.hax(ir,ic),location);
Had the same Problem : Don't preinitialize your axes-handles with doubles like :
h = zeros(1,3);
h(1) = subplot (1,3,1);
h(2) = subplot (1,3,2);
h(3) = subplot (1,3,3);
I got the issue with colorbar in this case, here is class (h(1)) "double" but it works without preinitialization :
clear h;
% h = zeros(1,3);
h(1) = subplot (1,3,1);
h(2) = subplot (1,3,2);
h(3) = subplot (1,3,3);
here is class(h(1)) "matlab.graphics.axis.Axes" like it should be.
Strange behavior in Matlab, the type "double" will not be overwritten.

Comment only

14 Nov 2014

subplot_grid
A subplot figure with a lot of fancy features

Joris,
I am curious if the save_figure() feature, to enable saving and reloading to a .fig file was ever implemented, as noted in your 7/14/2014 update. I don't see the functionality in the current version of the code, and this would be very useful to me if it worked smoothly. (I get the same errors as Alex when trying to reload a saved .fig).
Great tool though!!

5

30 Oct 2014

subplot_grid
A subplot figure with a lot of fancy features

Joris,
I'm sorry if I seem to be harping, but it looks like the set_padding method is not operational either. I don't find any reference to the loose_inset property in the reposition_content function. Is this something that you've worked on?
Thanks,
Dan

Comment only

20 Oct 2014

subplot_grid
A subplot figure with a lot of fancy features

Joris,
For my first item below, it can be eliminated by changing the code in the set_zoom_button_position as follows:
if verLessThan('matlab','8.4')
%DWK: Inlining the layering command provides modest speed improvement
% uistack(this.subplotzoom_data(ir,ic).zm_btn,'top');
parentObj = get(this.subplotzoom_data(ir,ic).zm_btn,'Parent');
allDescendents = get(parentObj,'Children');
% Only changing the layering if necessary makes a big difference
zmBtnIndex = find(allDescendents == this.subplotzoom_data(ir,ic).zm_btn,1);
thisAXIndex = find(allDescendents == this.hax(ir,ic),1);
if zmBtnIndex < thisAXIndex,
newOrder = [allDescendents(allDescendents~=this.subplotzoom_data(ir,ic).zm_btn);this.subplotzoom_data(ir,ic).zm_btn];
set(parentObj,'Children',newOrder);
end
end
On the other hand, I've found a new issue. The use of the colorbar method doesn't seem to be working. Every time I try to use it I get the following error:
Error using colorbar (line 55)
Attempt to reference field of non-structure array.
Error in subplot_grid/colorbar (line 2181)
hcb = colorbar('peer',this.hax(ir,ic),location);
Thanks,
Dan

Comment only