It's great. But there is a single problem about legend. When I run the code (in R2015b) like a one below
for m = 1:n
I always get the following error message.
Error using matlab.ui.Figure/set
Handles of type Legend cannot be made the current Axes.
Error in subplot1 (line 138)
Error in FigureMaster (line 23)
Please let me know how can i use legend with 'subplot1'
QUESTION: Is there a way to force the size of the subplot box to be perfectly square rather than a rectangle? And how to I force the axes to be all the same lengths . (i.e, X-axis is 0 to 25 and Y-axis is 0 to 25 for all subplots) ?? Thanks again!
Very helpful, thank you! This should be standard in matlab, the gap between subplots is such a waste of space.
One thing missing from this function is the ability to merge two subplot areas into a larger plot area for some charts, e.g. subplot(3,2,[1 3]) will make the top left subplot occupy spot 1 and 3 (and so be double size vertically). Can this be added to subplot1 somehow?
i had similar problems as Dave Van Tol above, with subplot1 giving error messages along the lines of:
??? Error using ==> set
uimenu handle passed to 'CurrentAxes' property - valid axes handle required
Error in ==> subplot1 at 138
His suggested fix worked perfectly (include in update?)
The function imagesc runs well. But mesh display the X-Y plane projection instead of the 3-D view as usual.
Do you have a solution for this?
13 Apr 2008
Thanks for the file.
Is it possible to create square subplots and still control the gap between plots? In the example below, how would one eliminate the excess space between columns?
%The goal is a 2*2 plot, in which each plot %is square and has equal length axes. %However, the figure has too much horizontal %space between columns.
plot_num = 0;
plot_num = plot_num + 1;
axis([-3 3 -3 3])
15 Feb 2008
Dave Van Tol
It helped me solve my problem.
One thing I have changed... subplot1 assumes that all of the children of the current figure are axes. That assumption is not always true. For example, turning on the data cursor (datacursormode on) adds a handle to the current figure. If that figure is reused, subplot1 mistakes that extra handle as an axes and the result is an error.
The root of the problem seems to be lines 111 and 112, which say:
H = get(gcf,'Children');
Ptot = length(H);
It would be good to eliminate the handles from H that are not axes. I have replaced line 112 with:
Ptot = sum(strcmp(get(H,'type'),'axes'));
That fixes the problem.
05 Oct 2007
It's very good. Save me a lot of time. It will be great if there is more information to talk about how to use it. For example, I just figured out, if you want to add a label in different subplot (e.g. 1st plot), you need to type >> subplot1(1); xlabel('time'). Overall, I like it a lot. Thanks!
15 Feb 2007
It's good. I like it
17 Nov 2006
I thought I can add labels to subplot rows and coloumns.... can someone show me how?
17 Nov 2006
I like the control over the gap size. But this creates axes where I do not intend to place any plots at all. Have to delete those one by one... and in reverse order, so that I do not stuff the internal structure subplot1 has set up.
24 Jan 2006
Note: If you do as Martin suggests (not a bad idea) only create the array of handles when nargout>0. This way when subplot is called wth no outputs, there will be no spewing of the unwanted handles array to the command line.
24 Jan 2006
Very good if you add the axes handles as output parameter.
You must change only the following lines: