Axes facets
daspi.plotlib.facets.AxesFacets(*, nrows=None, ncols=None, mosaic=None, sharex='none', sharey='none', width_ratios=None, height_ratios=None, stretch_figsize=False, **kwds)
¶
A class for creating a grid of subplots with customizable sharing and sizing options.
The class provides flexible handling the created Axes instances through its flat property and iteration capabilities:
- Flat property: Accesses Axes in a flattened view from left-to-right, top-to-bottom
- Axes property: Maintains the 2D structure for grid-based operations
- Iteration: Yields each axis instance coming from the Flat property sequentially to simplify plotting The class supports two different ways to create subplot layouts:
| PARAMETER | DESCRIPTION |
|---|---|
nrows
|
Number of rows of subplots in the grid, by default 1.
TYPE:
|
ncols
|
Number of columns of subplots in the grid, by default 1.
TYPE:
|
sharex
|
Controls sharing of properties along the x-axis, by default 'none'.
TYPE:
|
sharey
|
Controls sharing of properties along the y-axis, by default 'none'.
TYPE:
|
width_ratios
|
Relative widths of the columns, by default None.
TYPE:
|
height_ratios
|
Relative heights of the rows, by default None.
TYPE:
|
stretch_figsize
|
If True, the height and width of the figure are stretched based on the number rows and columns in the axes grid. If a float is provided, the figure size is stretched by the given factor. If a tuple of two floats is provided, the figure size is stretched by the given factors for the x and y axis, respectively. by default False.
TYPE:
|
**kwds
|
Additional keyword arguments to pass to the function
TYPE:
|
Examples:
-
Using nrows and ncols: Creates a regular grid of subplots with specified dimensions
-
Using mosaic: Creates a layout with custom subplot arrangements and spanning
-
Create a seaborn-style jointplot layout with custom size ratios:
import daspi as dsp # Creates a layout with main scatter plot and marginal distributions layout = [ ['hist_x', '.'], # '.' creates an empty/blank Axes ['scatter', 'hist_y']] facets = AxesFacets( mosaic=layout, width_ratios=[4, 1], # Make the marginal y-hist narrower height_ratios=[1, 4] # Make the marginal x-hist shorter )
This creates a figure with: - A main scatter plot in the bottom-left - A marginal histogram on top for x-distribution - A marginal histogram on right for y-distribution - Top-right cell is automatically empty using the '.' notation - Proportional spacing using width and height ratios
The '.' character is a special notation in matplotlib's mosaic layout that automatically creates an empty/invisible Axes, which is more efficient than creating a visible Axes and then hiding it.
figure
instance-attribute
¶
The figure instance to label.
axes
instance-attribute
¶
A 2D array containing the Axes instances of the figure.
mosaic
instance-attribute
¶
A visual layout of how the Axes are arranged labeled as strings.
figsize = (stretch_x * figsize[0], stretch_y * figsize[1])
instance-attribute
¶
The figsize passed when creating the subplots.
ax
property
¶
Get the axes that is currently being worked on. This property is automatically kept current when iterating through this class (read-only).
nrows
property
¶
Get the number of Axes rows in the grid (read-only).
ncols
property
¶
Get the number of Axes columns in the grid (read-only).
shape
property
¶
Get the shape of the axes array (read-only).
sharex
property
¶
Get the sharing of properties along the x-axis (read-only).
sharey
property
¶
Get the sharing of properties along the y-axis (read-only).
flat
property
¶
Get a list of all the Axes in the grid.
| RETURNS | DESCRIPTION |
|---|---|
List[Axes]
|
A list of all the Axes in the grid. |