Plotting Contexts¶
soundscapy.plotting.plot_context
¶
Data and state management for plotting layers.
This module provides the PlotContext class that manages data and state for ISOPlot visualizations, enabling a more flexible architecture for plot generation with support for layered visualizations and subplot management.
| CLASS | DESCRIPTION |
|---|---|
PlotContext |
Manages data and state for a plot or subplot. |
PlotContext
¶
PlotContext(
data: DataFrame | None = None,
x: str = "ISOPleasant",
y: str = "ISOEventful",
hue: str | None = None,
ax: Axes | None = None,
title: str | None = None,
)
Manages data and state for a plot or subplot.
This class centralizes the management of data, coordinates, and other state needed for rendering plot layers, allowing for consistent data access patterns and simplified layer implementation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
data |
The data associated with this context
|
x |
The column name for x-axis data
|
y |
The column name for y-axis data
|
hue |
The column name for color encoding, if any
|
ax |
The matplotlib Axes object this context is associated with
|
title |
The title for this context's plot
|
layers |
The visualization layers to be rendered on this context |
Initialize a PlotContext.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Data to be visualized
TYPE:
|
x
|
Column name for x-axis data
TYPE:
|
y
|
Column name for y-axis data
TYPE:
|
hue
|
Column name for color encoding
TYPE:
|
ax
|
Matplotlib axis to render on
TYPE:
|
title
|
Title for this plot context
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
create_child |
Create a child context that inherits properties from this context. |
Source code in src/soundscapy/plotting/plot_context.py
create_child
¶
create_child(
data: DataFrame | None = None,
title: str | None = None,
ax: Axes | None = None,
) -> PlotContext
Create a child context that inherits properties from this context.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Data for the child context. If None, inherits from parent.
TYPE:
|
title
|
Title for the child context
TYPE:
|
ax
|
Matplotlib axis for the child context
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PlotContext
|
A new child context with inherited properties |