 # what does numRows, numCols in subplot docs mean?

subplot(numRows, numCols, plotNum)

On my local disk, the file:

file:///usr/share/doc/python-matplotlib-doc/html/api/pyplot_api.html#matplotlib.pyplot.subplot

contains:

subplot(numRows, numCols, plotNum)

where plotNum = 1 is the first plot number and increasing plotNums
fill rows first. max(plotNum) == numRows * numCols

and then, a little later:

New subplots that overlap old will delete the old axes.

However, that doc does not explain what a row or column is or what
overlap means.

Is there some way the figure is partitioned into rows and columns and the
subplots appear in these rows and columns. If so, then how is this
partition
done? Does subplot(1,2,1) appear to the left and at same level as
subplot(1,2,2)?
What if there's subplot(1,2,1) and subplot(2,1,1). Do they overlap and
if so, why?
IOW, what's the definition of overlap?

TIA.

-regards,
Larry

Cc:
Bcc:
mean?
X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc

Larry Evans, on 2011-01-16 06:11, wrote:

subplot(numRows, numCols, plotNum)

New subplots that overlap old will delete the old axes.

However, that doc does not explain what a row or column is or what
overlap means.

Is there some way the figure is partitioned into rows and columns and the
subplots appear in these rows and columns. If so, then how is this
partition
done? Does subplot(1,2,1) appear to the left and at same level as
subplot(1,2,2)?
What if there's subplot(1,2,1) and subplot(2,1,1). Do they overlap and
if so, why?
IOW, what's the definition of overlap?

Hi Larry,

Overlap means identical parameters for subplot:
In : ax1 = plt.subplot(1,2,1)

In : ax2 = plt.subplot(1,2,2)

In : ax3 = plt.subplot(1,2,1) # overlap, will delete ax1

In : fig = plt.gcf()

In : fig.axes
Out:
[<matplotlib.axes.AxesSubplot object at 0xa1b582c>,
<matplotlib.axes.AxesSubplot object at 0xa33968c>]

In : ax1
Out: <matplotlib.axes.AxesSubplot object at 0xa1b582c>

In : ax2
Out: <matplotlib.axes.AxesSubplot object at 0xa33968c>

In : ax3
Out: <matplotlib.axes.AxesSubplot object at 0xa1b582c>

In : ax4 = plt.subplot(2,2,1) # also overlaps with ax3

In : ax5 = plt.subplot(2,2,4) # overlaps with ax2

In : fig.axes
Out:
[<matplotlib.axes.AxesSubplot object at 0xa49882c>,
<matplotlib.axes.AxesSubplot object at 0xa5118ac>]

The last parameter ("plotNum") for subplot determines which row
and column you want based on something like the formula:

row = plotNum // numCols
column = plotNum % numCols

Hope that helps,

···

From: Paul Ivanov <pivanov314@...287...>
To: Larry Evans <cppljevans@...2108...>
Subject: Re: [Matplotlib-users] what does numRows, numCols in subplot docs
--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7