Doug's MATLAB Video Tutorials

November 22nd, 2010

Subplot vs axes

Subplot is a convenience function that wraps around the lower level axes function. It simplifies the layout process. As a higher level function, it does some bookkeeping for you. This debugging session shows that the helpful things it does can be confusing if you are not expecting them.

4 Responses to “Subplot vs axes”

  1. Aurelien Queffurust replied on :

    Salut!

    This video shows exactly the problem I solved in MATLAB Central this month :
    http://www.mathworks.com/matlabcentral/newsreader/view_thread/296534#796561

    Maybe, we now could update this post to inform the user that there is now a video about overlapping of axes?

    Aurélien
    http://blog.developpez.com/matlab4geek/

  2. dhull replied on :

    @Aurelien,

    I just posted a link to that thread. I get the vast majority of my video ideas from questions I get via e-mail. I am glad to see I chose one that is of general interest.

    Thanks,
    Doug

  3. venkata replied on :

    Hi Doug,
    I solved the same problem that I encountered in my plotting. As a part of my publication I had to plot 11 figures in the same plot but it is horizontal split not the vertical as you discussed here.
    I used the same ‘position’ a little better way giving more space between subplots using
    “subplot(‘position’,[x y xlen ylen])” in the for loop.

    Your ideas are very tricky and solves the problems more easily.

    Thanks

  4. dhull replied on :

    @Venkata,

    I would not use subplot like you are. Subplot really just calls axes with a preset position. When you feed the position into subplot, it just gets passed into the axes command anyways. Might as well be more direct.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.