Skip to content

Layered-plotting#116

Merged
MitchellAcoustics merged 45 commits into
devfrom
layered-plotting
May 12, 2025
Merged

Layered-plotting#116
MitchellAcoustics merged 45 commits into
devfrom
layered-plotting

Conversation

@MitchellAcoustics

Copy link
Copy Markdown
Owner

No description provided.

Partially completed refactor. Working fairly well, still need to write tests and clean up code base.

- Removed the Plotly backend implementation due to its experimental status.
- Simplified the Seaborn backend by consolidating methods and improving type hints.
- Enhanced the CircumplexPlot class to support more flexible data handling and plotting.
- Updated utility functions and constants for better clarity and usability.
- Improved styling options and added detailed docstrings for better documentation.
- Ensured compatibility with the latest changes in the plotting utilities.
- Removed unused imports from plot_functions.py.
- Introduced plotting_types.py to define utility functions and constants for the plotting module.
- Deleted plotting_utils.py and stylers.py as their functionalities were integrated into the new structure.
- Updated relevant classes and functions to utilize the new plotting types and parameters.
- Updated CircumplexPlot class to use 'x' and 'y' parameters instead of 'xcol' and 'ycol'.
- Added new methods for data validation and hue checking in CircumplexPlot.
- Improved density plotting methods to streamline code and enhance readability.
- Introduced SPI score calculation functions and refactored existing methods for clarity.
- Updated tutorial notebook to reflect changes in parameter names and usage.
- Enhanced test cases for MultiSkewNorm to align with refactored SPI score method.
Deprecates CircumplexPlot in favor of new ISOPlot class with better API design
Improves coordinate calculation by normalizing around scale midpoint
Adds type safety and parameter validation throughout plotting module

Major improvements include:
- Better parameter handling and type validation
- Clearer separation of plotting responsibilities
- More robust legend and style handling
- Normalized ISO coordinate calculations
Re-enables density_plot and jointplot functions with improved type hints and documentation
Updates simple density parameters for better visualization defaults
Reorganizes imports and enhances parameter handling in jointplot

Makes plotting interface more consistent with modern Python practices while maintaining backwards compatibility
…on and styling options for circumplex visualizations. Adds validation for density plot data size.
…ng clarity and formatting of parameter descriptions.
Added proper deprecation warnings and included these in test_plotting_deprecated
@MitchellAcoustics MitchellAcoustics marked this pull request as ready for review May 8, 2025 01:52
Create modular architecture for ISOPlot with:
- PlotContext for managing data and state
- Layer abstraction system for visualization components
- Enhanced parameter management with PlotParams
- Support for targeted layer addition
- Fluent interface preserved for method chaining
…string examples, and improve type safety across layers and context management
… improved validation and type safety, streamline seaborn and density parameters, and enhance code clarity across plotting modules.
…nagement, and enhance type safety with new ParamModel integration.
Modernizes parameter management through enhanced type models and validation

- Introduces dedicated parameter models for better type safety
- Simplifies layer handling with cleaner inheritance
- Improves subplot management with dedicated params class
- Adds better control over figure/plot lifecycle with close/save wrappers
- Reorganizes plotting code for better maintainability
Restructures SPI plotting functionality to use a more flexible layered approach with better parameter management

- Updates density plotting parameters with cleaner threshold handling
- Improves type safety for plotting parameters
- Consolidates SPI-related plotting code into dedicated layer classes
- Adds better parameter validation and documentation

Part of the plotting system modernization effort
Enhances the SPI Layer implementation with flexible score display options:
- Enables showing SPI scores either on axis or under plot title
- Adds default styling parameters for score display
- Fixes data handling by filtering for relevant coordinates

Updates example code to demonstrate new score display functionality
- Updated SPILayer to accept `spi_target_data` instead of `custom_data`, allowing for clearer data handling.
- Added detailed docstrings for parameters in SPILayer to clarify usage and requirements.
- Implemented a warning mechanism when `custom_data` is used as a fallback for `spi_target_data`.
- Enhanced validation of SPI data shape to ensure it meets expected dimensions.
- Removed unused generator methods from PlotContext to streamline the codebase.
- Cleaned up imports in plot_functions.py by removing unnecessary collections.abc imports.
- Minor adjustments in plotting_types.py to prepare for future refactoring related to `include_outline`.
Reorganized `ISOPlot` and plotting functions to enhance modularity and maintainability. Introduced better logging, parameter handling, and improved subplot creation with streamlined support for `subplot_by`. Added optional return of `ISOPlot` objects for greater flexibility. Adjusted some deprecated or inconsistent parameter usages for clarity.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Cleaned up unused matplotlib and default parameter imports to improve code readability and maintainability. This helps reduce clutter and ensures only necessary dependencies are included.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Improves organization of subplot parameters by moving setup earlier in the process flow and encapsulating logic in SubplotsParams class

Updates test cases in plotting functions to skip matplotlib display commands and use subset of data for better test performance
…ation

- Introduced create_circumplex_subplots function to generate a grid of circumplex plots with customizable parameters.
- Updated ISOPlot class to validate hue parameter against both columns and index names in the provided DataFrame.
- Minor adjustments to the jointplot function to remove unused figsize height parameter.
Updated return types for plotting functions, removing references to `Self` and correcting type hints. Introduced `iso_plot` and `create_iso_subplots` for soundscape visualizations. Enhanced docstrings and addressed minor styling inconsistencies in the library configuration files.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Breaks down complex subplot creation logic into smaller, focused functions:
- Extracts data preparation into _prepare_subplot_data
- Moves subplot creation logic to _create_subplots
- Improves type hints and documentation clarity
- Removes optional parameter from data argument for better type safety

Makes the code more maintainable and easier to understand while maintaining existing functionality.
Replaces `apply_styling` with `style` for more concise API and improves error handling across plotting functions. Adds new experimental warning and centralizes several error messages for better consistency and maintainability. Several deprecated or redundant methods were removed or replaced with streamlined logic.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Replaced `ParamModel.create` with direct subclass instantiation for cleaner and more explicit parameter initialization. Improved flexibility in parameter updates by introducing `ignore_null` and utilizing Pydantic's native validation mechanisms. Updated plot functions with better defaults, added support for dynamic subtitle handling, and marked `create_circumplex_subplots` as deprecated in favor of `create_iso_subplots`.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Refactored parameter models to use dataclasses for better type validation and maintainability. Updated the `add_layer` methods to drop "data" key where needed. Added extensive test coverage for the new dataclass-based parameter logic, ensuring robust behavior across various scenarios.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Replaced `model_copy` with `copy` for parameter models to enhance clarity and consistency in various modules. Updated plotting logic, refined default values (e.g., `title_fontsize`), fixed bugs in SPI layer behavior, and streamlined testing by reorganizing tests and updating the test model naming conventions.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
Removed outdated backends documentation and replaced it with new plotting-related sections like `plot_functions` and `iso_plot`. Updated testing to ignore specific files (`iso_plot.py`) and enhanced config formatting consistency in `pyproject.toml` and `tox.ini`. Disabled certain pre-commit hooks temporarily for further refinement.

Signed-off-by: Andrew Mitchell <a.j.mitchell@ucl.ac.uk>
@MitchellAcoustics

Copy link
Copy Markdown
Owner Author

This pull request introduces significant updates to the soundscapy library, focusing on deprecating older plotting APIs, introducing new plotting capabilities, and improving documentation and configuration. The most notable changes include the removal of the CircumplexPlot API in favor of the new ISOPlot interface, updates to documentation to reflect these changes, and enhancements to configuration files for better development and testing support.

Deprecation and Replacement of Plotting APIs:

  • Removed the CircumplexPlot API and related functionality, replacing it with the new ISOPlot interface for soundscape plotting. (src/soundscapy/plotting/circumplex_plot.py, [1]; src/soundscapy/plotting/__init__.py, [2]
  • Introduced backends_deprecated.py to provide deprecation warnings for v0.7 APIs like CircumplexPlot, Backend, and StyleOptions. (src/soundscapy/plotting/backends_deprecated.py, src/soundscapy/plotting/backends_deprecated.pyR1-R75)

Documentation Updates:

  • Updated the documentation to reflect the new ISOPlot API, removing references to deprecated CircumplexPlot functionality and adding new pages for ISOPlot and plot_functions. (docs/reference/plotting.md, [1]; docs/reference/plotting/iso_plot.md, [2]; docs/reference/plotting/plot_functions.md, [3]
  • Adjusted the navigation structure in mkdocs.yml to include new documentation files and remove deprecated ones. (mkdocs.yml, mkdocs.ymlL31-R32)

Configuration and Dependency Enhancements:

  • Added types-seaborn to development dependencies and removed plotly from the main dependencies. (pyproject.toml, [1] [2]
  • Enabled the numpy.typing.mypy_plugin for improved type checking and added new linting rules and per-file ignores in pyproject.toml. (pyproject.toml, [1] [2]

Codebase Enhancements:

  • Introduced a new defaults.py module to centralize default parameters and constants for plotting, ensuring consistency across the library. (src/soundscapy/plotting/defaults.py, src/soundscapy/plotting/defaults.pyR1-R102)
  • Improved function signatures in audio/binaural.py to use keyword-only arguments for better readability and maintainability. (src/soundscapy/audio/binaural.py, [1] [2]

Minor Improvements:

  • Suppressed specific linting warnings in audio_analysis.py for better code clarity. (src/soundscapy/audio/audio_analysis.py, src/soundscapy/audio/audio_analysis.pyL166-R166)
  • Updated the __init__.py files to reflect the new plotting API and remove deprecated imports. (src/soundscapy/__init__.py, [1]; src/soundscapy/plotting/__init__.py, [2]

These changes collectively modernize the soundscapy library, streamline its plotting capabilities, and improve its maintainability and usability.

@MitchellAcoustics MitchellAcoustics merged commit 6e79ee8 into dev May 12, 2025
17 checks passed
@MitchellAcoustics MitchellAcoustics deleted the layered-plotting branch May 12, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant