Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 211 used in plt.subplot(211)

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?

like image 734
Dan Avatar asked Nov 04 '16 00:11

Dan


People also ask

What does PLT subplot 1 2 1 mean?

The subplot() Function The layout is organized in rows and columns, which are represented by the first and second argument. The third argument represents the index of the current plot. plt.subplot(1, 2, 1) #the figure has 1 row, 2 columns, and this plot is the first plot.

What will PLT subplot 333 do?

subplot(333) do? Create a blank plot that fills the figure. Create a plot with three points at location (3,3). Create a smaller subplot in the topleft of the figure.

What is the equivalent of subplot 111?

What is the equivalent of subplot (1, 1, 1)? Explanation: While using subplot (1,1,1), we have allocated memory as a 2-D matrix for only 1 graph. This is similar to the axes command which generates an empty graph.

What is index in PLT subplot?

subplot(subplot(nrows, ncols, index) In the current figure, the function creates and returns an Axes object, at position index of a grid of nrows by ncolsaxes. Indexes go from 1 to nrows * ncols, incrementing in row-major order. Ifnrows, ncols and index are all less than 10.


1 Answers

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.

From the docs:

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, and plot_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 of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_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).

like image 168
tmdavison Avatar answered Oct 13 '22 00:10

tmdavison