subplot

Hi,

Jae-Joon Lee <lee.j.joon@...83...> writes:

I had a few off-list conversation with Alan, and I'm also quite agree
with him for this issue.

[...]

issue 2) It is not easy (actually impossible) to make an axes
spanning multiple cells.

Regarding this 2nd issue, I appreciated long ago the flexibility and ease-of-use
offered by super-mongo WINDOW command (e.g.
http://www.astro.princeton.edu/~rhl/sm/sm.html#SYN83). Basically, this would be
the same as accepting a tuple as plotNum argument in matplotlib subplot(numRows,
numCols, plotNum) to specify the extent of the composed subplot in terms of
atomic subplots, e.g.

ax1 = subplot(2,2,(1,3))
ax2 = subplot(2,2,2)
ax3 = subplot(2,2,4)

would produce the following layout:

···

+-------+-------+

      > ax2 |
      > >
ax1 +-------+
      > ax3 |
      > >

+-------+-------+

or

ax1 = subplot(3,3,(1,5))
ax2 = subplot(3,3,(7,9))
ax3 = subplot(3,3,(3,6))

for

+-------+---+

      > >
ax1 |ax3|
      > >

+-------+---+

   ax2 |

+-----------+

My current naive implementation is the following:

def add_axes(fig, nrow, ncol, extent, **kwargs):

    pars = fig.subplotpars
    figW = pars.right-pars.left # Fig size
    figH = pars.top-pars.bottom
    subW = figW / (ncol + pars.wspace*(ncol-1)) # Sub-axes size
    subH = figH / (nrow + pars.hspace*(nrow-1))
    sepW = pars.wspace*subW # Separations
    sepH = pars.hspace*subH

    axL,axR,axB,axT = 1,0,1,0
    for num in extent:
        assert 0<num<=nrow*ncol
        irow, icol = divmod(num-1, ncol)
        subL = pars.left + icol*(subW + sepW)
        subB = pars.top - (irow+1)*subH - irow*sepH
        axL = min(axL,subL)
        axR = max(axR,subL+subW)
        axB = min(axB,subB)
        axT = max(axT,subB+subH)
    axW = axR-axL
    axH = axT-axB

    return fig.add_axes([axL,axB,axW,axH], **kwargs)

fig = figure()
ax1 = add_axes(fig,3,3,(1,5))
ax2 = add_axes(fig,3,3,(7,9))
ax3 = add_axes(fig,3,3,(3,6))
ax1.plot(randn(10),'b.')
ax2.plot(randn(10),'r.')
ax3.plot(randn(10),'g.')
draw()

Cheers.

The functionality is good,
but the syntax is awful.

Using a location along with
a rowspan and colspan is a
very established convention.
(E.g., consider the tkinter
grid manager.) It is
completely explicit and
simple, even when changing
the extent in only a single
direction.

subplot2grid(loc=(0,0), rowspan=2, colspan=3)

would confuse nobody (or so I claim).

Alan

···

On 5/18/2009 4:27 PM Yannick Copin apparently wrote:

super-mongo WINDOW command (e.g.
http://www.astro.princeton.edu/~rhl/sm/sm.html#SYN83)

Hi guys,

+1 for rowspan and colspan. Much cleaner I would say.

Chaitanya

···

On Mon, May 18, 2009 at 11:17 PM, Alan G Isaac <alan.isaac@...287...> wrote:

On 5/18/2009 4:27 PM Yannick Copin apparently wrote:

super-mongo WINDOW command (e.g.
http://www.astro.princeton.edu/~rhl/sm/sm.html#SYN83)

The functionality is good,
but the syntax is awful.

Using a location along with
a rowspan and colspan is a
very established convention.
(E.g., consider the tkinter
grid manager.) It is
completely explicit and
simple, even when changing
the extent in only a single
direction.

subplot2grid(loc=(0,0), rowspan=2, colspan=3)

would confuse nobody (or so I claim).

Alan

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

That should have been:
subplot2grid(shape=(3,3), loc=(0,0), rowspan=2, colspan=3)

Alan Isaac

···

On 5/18/2009 5:17 PM Alan G Isaac apparently wrote:

subplot2grid(loc=(0,0), rowspan=2, colspan=3)
would confuse nobody (or so I claim).

Alan G Isaac wrote:

Using a location along with
a rowspan and colspan is a
very established convention.

This is used by the wxPython GridBagSizer as well.

Speaking of which, I recall a good while back someone was working on a axes layout system modeled after wx Sizers -- anyone know what happened to that?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Alan G Isaac wrote:

Using a location along with
a rowspan and colspan is a
very established convention.

This is used by the wxPython GridBagSizer as well.

Speaking of which, I recall a good while back someone was working on a
axes layout system modeled after wx Sizers -- anyone know what happened
to that?

I guess you're referring to mplsizer by Andrew Straw?

http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/toolkits/mplsizer/

-JJ

···

On Tue, May 19, 2009 at 12:51 PM, Christopher Barker <Chris.Barker@...259...> wrote:

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Jae-Joon Lee wrote:

I guess you're referring to mplsizer by Andrew Straw?

http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/toolkits/mplsizer/

yup -- that's it. It looks like it hasn't been touched in a year or so. Maybe this is a good time to revive it? I think it's a great idea.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...