predict-idlab / plotly-resampler

Visualize large time series data with plotly.py
https://predict-idlab.github.io/plotly-resampler/latest
MIT License
1k stars 67 forks source link

No support for text-per-marker or color-per-marker #224

Closed Broundal closed 1 year ago

Broundal commented 1 year ago

Hello, I've noted that resampled graphs does not show markers' color/text correctly when color/text are passed as list to the trace. Example below. Expected behaviour - Hovering markers should show "text" that matches "y". Additionally, peaks should be marked in black. Current behavior - mismatch between "text" and "y" values. No points are marked in black.

The graph is plotted correctly if FigureReampler is not used.

import numpy as np
import plotly.graph_objects as go
from plotly_resampler import FigureResampler
import pandas as pd

fig = FigureResampler(go.Figure())

x= pd.date_range('1-1-2000', '1-1-2001', periods=2000)
y=np.sin(100*np.arange(len(x))/len(x))
trace = go.Scatter(x=x, y=y,
                   marker={'color': ['black' if yi>=0.99 else 'blue' for yi in y]},
                   text=[f'text: {yi}, color:{"black" if yi>=0.99 else "blue"}' for yi in y],
                   )
fig.add_trace(trace)
fig.show()

Thanks in advance!

jvdd commented 1 year ago

Thx for uncovering this bug @Broundal

I successfully replicated the issue using the minimal code you provided and have submitted a fix in PR #225.

I will notify you as soon as we have a new pre-release that includes this fix.

jonasvdd commented 1 year ago

Hi @Broundal,

Thanks for reporting this issue! This should be fixed in plotly-resampler==0.9.0rc6.