Code Documentation¶
Implementations of the GridStrategy class to easily graph multiple plots.
This is the code documentation for the implementation of ‘SquareStrategy’ and ‘RectangularStrategy’.
SquareStrategy¶
-
class
grid_strategy.strategies.
SquareStrategy
(alignment='center')[source]¶ -
classmethod
arrange_rows
(n, x, y)[source]¶ Given a grid of size (
x
xy
) to be filled withn
plots, this arranges them as desired.Parameters: - n – The number of plots in the subplot.
- x – The number of columns in the grid.
- y – The number of rows in the grid.
Returns: Returns a
tuple
containing a grid arrangement, seeget_grid()
for details.
-
classmethod
get_grid_arrangement
(n)[source]¶ Return an arrangement of rows containing
n
axes that is as close to square as looks good.Parameters: n – The number of plots in the subplot Returns: Returns a tuple
of lengthnrows
, where each element represents the number of plots in that row, so for example a 3 x 2 grid would be represented as(3, 3)
, because there are 2 rows of length 3.Example:
>>> GridStrategy.get_grid(7) (2, 3, 2) >>> GridStrategy.get_grid(6) (3, 3)
-
classmethod
stripe_even
(n_more, more_val, n_less, less_val)[source]¶ Prepare striping for an even number of rows.
Parameters: - n_more – The number of rows with the value that there’s more of
- more_val – The value that there’s more of
- n_less – The number of rows that there’s less of
- less_val – The value that there’s less of
Returns: Returns a
tuple
of striped values with appropriate buffer.
-
classmethod
stripe_odd
(n_more, more_val, n_less, less_val)[source]¶ Prepare striping for an odd number of rows.
Parameters: - n_more – The number of rows with the value that there’s more of
- more_val – The value that there’s more of
- n_less – The number of rows that there’s less of
- less_val – The value that there’s less of
Returns: Returns a
tuple
of striped values with appropriate buffer.
-
classmethod
RectanglularStrategy¶
-
class
grid_strategy.strategies.
RectangularStrategy
(alignment='center')[source]¶ Provide a nearest-to-square rectangular grid.
-
classmethod
get_grid_arrangement
(n)[source]¶ Retrieves the grid arrangement that is the nearest-to-square rectangular arrangement of plots.
Parameters: n – The number of subplots in the plot. Returns: Returns a tuple
of lengthnrows
, where each element represents the number of plots in that row, so for example a 3 x 2 grid would be represented as(3, 3)
, because there are 2 rows of length 3.
-
classmethod