pyopenms_viz icon indicating copy to clipboard operation
pyopenms_viz copied to clipboard

Simplifying MultiPlot Interface #83

Open Nishantrde opened this issue 8 months ago • 3 comments

feat(ChromatogramPlot): Add tile_by parameter for automated subplot creation

  • Introduced the tile_by parameter in ChromatogramPlot to split data into subplots automatically.
  • Eliminated the need for manual canvas specification by handling subplot creation internally.
  • Added validation to ensure the tile_by column exists in both the chromatogram and annotation data.
  • Refactored code with a helper function to reduce duplication.
  • Updated documentation and tests for the new functionality.

Summary by CodeRabbit

  • New Features
    • Enhanced plotting capabilities now automatically group and tile visualizations, offering improved clarity and a more organized layout.
    • Expanded configuration options empower users to customize plot arrangements, including multi-run spectrum analysis with refined grid layouts.
  • Refactor
    • Simplified error handling and streamlined plotting logic enhance stability and performance.

Nishantrde avatar Mar 26 '25 05:03 Nishantrde

Walkthrough

This pull request enhances plotting capabilities across multiple modules. Gallery scripts now automate subplot creation using a new facet_column parameter to group data, while the spectrum binning script supports multiple runs and a revised subplot layout. In internal modules, new configuration attributes (facet_column, facet_col_wrap) and validation logic have been added to support tiled layouts. Additionally, new methods in the Matplotlib plotting class manage subplot grid creation and axis cleanup. Minor updates include refined error handling, adjusted import statements, and small test file formatting changes.

Changes

File(s) Change Summary
docs/gallery_scripts_template/plot_spyogenes_subplots_ms_matplotlib.py
docs/gallery_scripts_template/plot_investigate_spectrum_binning_ms_matplotlib.py
Enhanced plotting logic to automate subplot creation using a facet_column, update subplot layouts (including a 4x2 grid for spectrum binning), and modify error and display handling.
pyopenms_viz/_config.py
pyopenms_viz/_core.py
Added new attributes (facet_column, facet_col_wrap) to plotting configuration; restructured ChromatogramPlot.plot() with configuration validation and subplot grouping.
pyopenms_viz/__init__.py Inserted a commented-out placeholder argument (tile_by) within the PlotAccessor class.
pyopenms_viz/_matplotlib/core.py Introduced three new utility methods (_compute_y_range_and_padding, _create_subplots, _delete_extra_axes) for subplot management and set the Matplotlib backend to "Agg".
test/conftest.py
test/test_spectrum.py
Added extra imports and a commented-out dynamic path resolution line; adjusted formatting (e.g. insertion of a blank line).

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Application
    participant CP as ChromatogramPlot
    participant DF as DataFrame

    U->>CP: Call plot()
    CP->>CP: _validate_plot_config()
    alt Valid facet_column
        CP->>DF: Group data by facet_column
        DF-->>CP: Return grouped data
        CP->>CP: Create subplots and prepare tooltips
    else Invalid facet_column
        CP->>CP: Fallback to single plot logic
    end
    CP-->>U: Display plot with subplots

Possibly related PRs

  • OpenMS/pyopenms_viz#82: Modifies subplot management and plot display methods, aligning closely with these plotting enhancements.
  • OpenMS/pyopenms_viz#57: Involves similar enhancements in plotting functionality by introducing grouping parameters.
  • OpenMS/pyopenms_viz#39: Introduces the facet_column parameter, directly relating to the new subplot configuration methods.

Suggested reviewers

  • jcharkow

Poem

I'm a rabbit, hopping through code with glee,
Plotting data in subplots as neat as can be.
Facets and grids now dance in a row,
Each run and axis in a neat, tiled show.
I nibble through changes, swift and bright,
Celebrating each line from morning till night.
Carrots and code—what a delightful sight!

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Mar 26 '25 05:03 coderabbitai[bot]

Hi @jcharkow I have solved most of the conflicts if you want you can review it.

Nishantrde avatar Mar 31 '25 17:03 Nishantrde

Hi @jcharkow I have solved most of the conflicts if you want you can review it.

I'll wait untill all the conflicts are solved and then I'll review

jcharkow avatar Mar 31 '25 20:03 jcharkow