pyopenms_viz icon indicating copy to clipboard operation
pyopenms_viz copied to clipboard

The output is not displayed properly in SpectrumPlot.

Open hjn0415a opened this issue 8 months ago • 5 comments

When viewing MS data, the output is not displayed properly, as shown below. I'd like to solve this problem - could you point out which part I should check?

Image

Image

hjn0415a avatar Apr 25 '25 02:04 hjn0415a

Thanks for reporting. The plotly spectrum example in the docs seems to be working fine as expected.

Can you provide a bit more information (reprex) to how you produced the plot so we can figure out what the issue is? The tooltips are set in the _add_tooltips method of the backend specific plotting engine. That would be a good place to start.

singjc avatar Apr 25 '25 16:04 singjc

I produced the plot using the Streamlit template.

Image

Okay, thanks. I'll check the _add_tooltips method more thoroughly.

hjn0415a avatar Apr 29 '25 00:04 hjn0415a

@singjc

Hi, Thanks for feedback.

I checked docs link you sent. However, That links to Bokeh Plot, Not Plotly plot.

Could you check this link?

https://pyopenms-viz.readthedocs.io/en/latest/gallery/ms_plotly/plot_spectrum_ms_plotly.html

Image

The actual value isn't 102, but the tooltip shows 102.

JKVISION1101 avatar Apr 30 '25 06:04 JKVISION1101

@singjc

Hi, Thanks for feedback.

I checked docs link you sent. However, That links to Bokeh Plot, Not Plotly plot.

Could you check this link?

https://pyopenms-viz.readthedocs.io/en/latest/gallery/ms_plotly/plot_spectrum_ms_plotly.html

Image

The actual value isn't 102, but the tooltip shows 102.

Ahh, I see. There seems to be the same issue for the chromatogram plot, the peakmap plot seems fine though. There must be something wrong with the tooltip data setup, probably incorrect key : value matching in pyopenms_viz/_plotly/core.py#L547.

singjc avatar Apr 30 '25 14:04 singjc

@singjc

I resolved the issue by modifying the part in the _add_tooltips method that updates customdata in fig.data, and now the data is displayed correctly as shown in the attached image. However, I'm not sure what needs to be modified for the chromatogram and the streamlit-template.

In Streamlit, when a graph is displayed and the length of fig.data is 1, the _add_tooltips method calls fig.update_traces and directly assigns custom_hover_data to customdata. I think this part is causing the issue. I don't understand why the update_traces method is called when the length of fig.data is not greater than 1. Can you explain what the update_traces method does?

Image

hjn0415a avatar May 08 '25 06:05 hjn0415a