Reputation: 263
In the pyplot documentation I saw
plt.subplt(211) which is identical to subplot(2, 1, 1)
I've also seen 211 being used elsewhere. Why specifically are those numbers being used as opposed to other ones?
Upvotes: 7
Views: 19877
Reputation: 69136
plt.subplot
takes three arguments, the number of rows (nrows
), the number of columns (ncols
) and the plot number. Using the 3-digit code is a convenience function provided for when nrows
, ncols
and plot_number
are all <10
.
So, 211
is equivalent to nrows=2
, ncols=1
, plot_number=1
.
Return a subplot axes positioned by the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure into
nrows * ncols
sub-axes, andplot_number
is used to identify the particular subplot that this function is to create within the notional grid.plot_number
starts at 1, increments across rows first and has a maximum ofnrows * ncols
.In the case when
nrows
,ncols
andplot_number
are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds representnrows
, the tens representncols
and the units representplot_number
. For instance:subplot(211)
produces a subaxes in a figure which represents the top plot (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
Upvotes: 15