Plotting Layers¶
soundscapy.plotting.layers
¶
Layer-based visualization components for plotting.
This module provides a system of layer classes that implement different visualization techniques for ISO plots. Each layer encapsulates a specific visualization method and knows how to render itself on a given context.
| CLASS | DESCRIPTION |
|---|---|
Layer |
Base class for all visualization layers. |
ScatterLayer |
Layer for rendering scatter plots. |
DensityLayer |
Layer for rendering kernel density plots. |
SimpleDensityLayer |
Layer for rendering simplified density plots with fewer contour levels. |
SPILayer |
Layer for rendering SPI plots. |
SPISimpleLayer |
Layer for rendering simplified SPI plots with fewer contour levels. |
SPIDensityLayer |
Layer for rendering simplified SPI plots with fewer contour levels. |
SPIScatterLayer |
Layer for rendering simplified SPI plots with fewer contour levels. |
Layer
¶
Layer(
custom_data: DataFrame | None = None,
param_model: type[SeabornParams] = SeabornParams,
**params: Any,
)
Base class for all visualization layers.
A Layer encapsulates a specific visualization technique and its associated parameters. Layers know how to render themselves onto a PlotContext's axes.
| ATTRIBUTE | DESCRIPTION |
|---|---|
custom_data |
Optional custom data for this specific layer, overriding context data
TYPE:
|
params |
Parameter model instance for this layer
TYPE:
|
Initialize a Layer.
| PARAMETER | DESCRIPTION |
|---|---|
custom_data
|
Optional custom data for this specific layer, overriding context data
TYPE:
|
param_model
|
The parameter model class to use, if None uses a generic ParamModel
TYPE:
|
**params
|
Parameters for the layer
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
render |
Render this layer on the given context. |
Source code in src/soundscapy/plotting/layers.py
render
¶
Render this layer on the given context.
| PARAMETER | DESCRIPTION |
|---|---|
context
|
The context containing data and axes for rendering
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
ScatterLayer
¶
Bases: Layer
Layer for rendering scatter plots.
Initialize a ScatterLayer.
| PARAMETER | DESCRIPTION |
|---|---|
custom_data
|
Optional custom data for this specific layer
TYPE:
|
**params
|
Parameters for the scatter plot
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
DensityLayer
¶
DensityLayer(
custom_data: DataFrame | None = None,
*,
param_model: type[DensityParams] = DensityParams,
include_outline: bool = False,
**params: Any,
)
Bases: Layer
Layer for rendering kernel density plots.
Initialize a DensityLayer.
| PARAMETER | DESCRIPTION |
|---|---|
custom_data
|
Optional custom data for this specific layer
TYPE:
|
include_outline
|
Whether to include an outline around the density plot
TYPE:
|
**params
|
Parameters for the density plot
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
SimpleDensityLayer
¶
SimpleDensityLayer(
custom_data: DataFrame | None = None,
*,
include_outline: bool = True,
param_model: type[
SimpleDensityParams
] = SimpleDensityParams,
**params: Any,
)
Bases: DensityLayer
Layer for rendering simplified density plots with fewer contour levels.
Initialize a SimpleDensityLayer.
| PARAMETER | DESCRIPTION |
|---|---|
custom_data
|
Optional custom data for this specific layer
TYPE:
|
include_outline
|
Whether to include an outline around the density plot
TYPE:
|
**params
|
Parameters for the density plot
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
SPILayer
¶
SPILayer(
spi_target_data: DataFrame | ndarray | None = None,
*,
msn_params: DirectParams | CentredParams | None = None,
n: int = 10000,
param_model: type[SPISeabornParams] = SPISeabornParams,
**params: Any,
)
Bases: Layer
Layer for rendering SPI plots.
Initialize an SPILayer.
| PARAMETER | DESCRIPTION |
|---|---|
spi_target_data
|
Pre-sampled data for SPI target distribution. When None, msn_params must be provided.
TYPE:
|
msn_params
|
Parameters to generate SPI data if no spi_target_data is provided
TYPE:
|
n
|
Number of samples to generate if using msn_params
TYPE:
|
param_model
|
The parameter model class to use
TYPE:
|
**params
|
Parameters for the layer. For compatibility with other layers, if 'custom_data' is present and spi_target_data is None, custom_data will be used as the SPI target data.
TYPE:
|
Notes
Either spi_target_data or msn_params must be provided, but not both. The test data for SPI calculations will be retrieved from the plot context.
| METHOD | DESCRIPTION |
|---|---|
render |
Render this layer on the given context. |
show_score |
Show the SPI score on the plot. |
Source code in src/soundscapy/plotting/layers.py
render
¶
Render this layer on the given context.
| PARAMETER | DESCRIPTION |
|---|---|
context
|
The context containing data and axes for rendering
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
show_score
¶
show_score(
spi_sc: int | None,
show_score: Literal["on axis", "under title"],
context: PlotContext,
ax: Axes,
axis_text_kwargs: dict[str, Any],
) -> None
Show the SPI score on the plot.
| PARAMETER | DESCRIPTION |
|---|---|
spi_sc
|
The SPI score to show
TYPE:
|
show_score
|
Where to show the score
TYPE:
|
context
|
The context containing data and axes for rendering
TYPE:
|
ax
|
The axes to render the score on
TYPE:
|
axis_text_kwargs
|
Additional arguments for the axis text |
Source code in src/soundscapy/plotting/layers.py
SPISimpleLayer
¶
SPISimpleLayer(
spi_target_data: DataFrame | ndarray | None = None,
*,
msn_params: DirectParams | CentredParams | None = None,
include_outline: bool = True,
**params: Any,
)
Bases: SPILayer, SimpleDensityLayer
Layer for rendering simplified SPI plots with fewer contour levels.
Initialize an SPISimpleLayer.
| PARAMETER | DESCRIPTION |
|---|---|
spi_target_data
|
Optional SPI target data for this specific layer
TYPE:
|
msn_params
|
Parameters to generate SPI data if no custom data is provided
TYPE:
|
include_outline
|
Whether to include an outline around the density plot
TYPE:
|
**params
|
Parameters for the density plot
TYPE:
|
Source code in src/soundscapy/plotting/layers.py
SPIDensityLayer
¶
Bases: SPILayer, DensityLayer
Layer for rendering simplified SPI plots with fewer contour levels.
Initialize SPIDensityLayer.
This initialization is not supported and will raise NotImplementedError. Use SPISimpleLayer instead.
Source code in src/soundscapy/plotting/layers.py
SPIScatterLayer
¶
Bases: SPILayer, ScatterLayer
Layer for rendering simplified SPI plots with fewer contour levels.
Initialize SPIScatterLayer.
This initialization is not supported and will raise NotImplementedError. Use SPISimpleLayer instead.