streamsim.src.core.config module
Configuration of plotting setup for the streaming framework.
- class streamsim.src.core.config.PlottingSetup(fig: Any, ax: Any, artists: Dict[str, Any] = None, xlim: Tuple[float, float] = None, ylim: Tuple[float, float] = None, title: str = 'Streaming Data Visualization')[source]
Bases:
objectEncapsulates matplotlib figure and axes configuration for streaming visualizations.
This class serves as a centralized container for managing plot setup state, including figure/axes references, artist collections, and axis limits. It provides a clean interface for initializing and configuring matplotlib plots used in real-time streaming applications.
- fig
Matplotlib Figure instance. Typically created via plt.figure() or plt.subplots() before passing to this class.
- Type:
Any
- ax
Matplotlib Axes instance where data will be rendered. This is the primary plotting surface for streaming visualizations.
- Type:
Any
- artists
Dictionary mapping names to matplotlib artists (lines, markers, patches, etc.) managed by this setup. Enables organized retrieval and updates during animation loops. Defaults to empty dict.
- Type:
Dict[str, Any]
- xlim
Optional x-axis bounds as (min, max). If None, axes auto-scale. Defaults to None.
- Type:
Tuple[float, float] | None
- ylim
Optional y-axis bounds as (min, max). If None, axes auto-scale. Defaults to None.
- Type:
Tuple[float, float] | None
- title
Plot title displayed above the axes. Defaults to “Streaming Data Visualization”.
- Type:
str
- configure()[source]
Applies the configured title and axis limits to the axes instance. Should be called once during initialization.
Example
>>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots() >>> setup = PlottingSetup( ... fig=fig, ... ax=ax, ... xlim=(0, 100), ... ylim=(-1, 1), ... title="Real-time ECG Monitor" ... ) >>> setup.configure() >>> # Later, store artists for tracking >>> setup.artists['signal'] = ax.plot([], [])[0]
Note
The Any type hints for fig and ax are used for flexibility across matplotlib backends. In practice, these should be matplotlib.figure.Figure and matplotlib.axes.Axes instances respectively.
See also
StreamingRenderer: Base class that consumes PlottingSetup for rendering.
- configure() None[source]
Apply initial configuration to the axes instance.
Sets the plot title and applies fixed axis limits if specified. This method should be called once after instantiation to ensure consistent initial plot appearance.
- Side Effects:
Modifies the ax instance in-place by setting title and limits.
Example
>>> setup = PlottingSetup(fig=fig, ax=ax, title="My Plot") >>> setup.configure() # Title now visible on axes