mplsoccer.grid module
Functions to plot a grid of axes with an endnote and title.
- mplsoccer.grid.grid(ax_aspect=1, figheight=9, nrows=1, ncols=1, grid_height=0.715, grid_width=0.95, space=0.05, left=None, bottom=None, endnote_height=0, endnote_space=0.01, title_height=0, title_space=0.01, axis=True, grid_key='grid')[source]
Create a grid of axes in a specified location
- Parameters:
ax_aspect (float, default 1) – The aspect ratio of the grid’s axis (width divided by height).
figheight (float, default 9) – The figure height in inches.
nrows, ncols (int, default 1) – Number of rows/columns of axes in the grid.
grid_height (float, default 0.715) – The height of the grid in fractions of the figure height. The default is the grid height is 71.5% of the figure height.
grid_width (float, default 0.95) – The width of the grid in fractions of the figure width. The default is the grid is 95% of the figure width.
space (float, default 0.05) – The total amount of the grid height reserved for spacing between the grid axes. Expressed as a fraction of the grid_height. The default is 5% of the grid height. The spacing across the grid width is automatically calculated to maintain even spacing.
left (float, default None) – The location of the left-hand side of the axes in fractions of the figure width. The default of None places the axes in the middle of the figure.
bottom (float, default None) – The location of the bottom endnote axes in fractions of the figure height. The default of None places the axes in the middle of the figure. If the endnote_height=0 then the grid is located at the bottom coordinate instead.
endnote_height (float, default 0) – The height of the endnote axes in fractions of the figure height. For, example 0.07 means the endnote axis is 7% of the figure height. If endnote_height=0 (default), then the endnote axes is not plotted.
endnote_space (float, default 0.01) – The space between the grid and endnote axis in fractions of the figure height. The default space is 1% of the figure height. If endnote_height=0, then the endnote_space is set to zero.
title_height (float, default 0) – The height of the title axis in fractions of the figure height. For, example 0.15 means the title axis is 15% of the figure height. If title_height=0 (default), then the title axes is not plotted.
title_space (float, default 0.01) – The space between the grid and title axis in fractions of the figure height. The default space is 1% of the figure height. If title_height=0, then the title_space is set to zero.
axis (bool, default True) – Whether the endnote and title axes are ‘on’.
grid_key (str, default grid) – The dictionary key for the main axes in the grid.
- Returns:
fig (matplotlib.figure.Figure)
axs (dict[label, Axes]) – A dictionary mapping the labels to the Axes objects.
- mplsoccer.grid.grid_dimensions(ax_aspect, figwidth, figheight, nrows, ncols, max_grid, space)[source]
Propose a grid_width and grid_height for grid based on the inputs.
- Parameters:
ax_aspect (float, default 1) – The aspect ratio of the grid’s axis (width divided by height).
figwidth, figheight (float) – The figure width/height in inches.
nrows, ncols (int) – Number of rows/columns of axes in the grid.
max_grid (float) – The longest side of the grid in fractions of the figure width / height. Should be between zero and one.
space (float) – The total amount of the grid height reserved for spacing between the grid axes. Expressed as a fraction of the grid_height.
- Returns:
grid_width, grid_height
- Return type:
the suggested grid_width and grid_height