Spectrum plot optimization#45
Spectrum plot optimization#45singjc merged 15 commits intoOpenMS:mainfrom axelwalter:spectrum-plot-optimization
Conversation
- one vline plot per peak results in bad performance with larger spectra - here, peaks with the same color are grouped and plotted together as one line - adaptations to _get_colors
- highest: custom peak_color - second: ion_annotation - lowest: by column
- add line width and color as parameters
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨Explore these optional code suggestions:
|
- use figure returned by plot method - set show_plot to False
singjc
left a comment
There was a problem hiding this comment.
Thanks for the update to spectrum plotting! It's super fast now! 🚀
Looks good to merge to me.
User description
Plotting each peak as a single vertical line turned out to be slow with interactive plots (Ploty and Bokeh) since each peak is represented by a separate trace.
Here, I modified the spectrum plotting to group peaks by color (according to priorities 1. custom peak color, 2. group by and 3. ion annotation) and plot them together as a single line (connected on the x-axis). This means each peak is described by three data points in the line (y=0, y=intensity, y=0). Connections on the x-axis are hidden by a h-line.
This reduced the number of traces down to a few, resulting in much better performance (tested on real spectra with thousands of peaks) and instant plot generation.
Main changes:
Due to these changes I set binning to False by default, since plotting large number of peaks is not an issue any more.
PR Type
enhancement
Description
Changes walkthrough 📝
_core.py
Optimize spectrum plotting with line plots and enhanced tooltipspyopenms_viz/_core.py
tooltips.
core.py
Enhance Plotly plotting with annotations and tooltipspyopenms_viz/_plotly/core.py
core.py
Improve Bokeh plotting with annotations and tooltipspyopenms_viz/_bokeh/core.py
core.py
Enhance Matplotlib plotting with annotations and x-axis customizationpyopenms_viz/_matplotlib/core.py
Spectrum.ipynb
...nbs/Spectrum.ipynb
...