You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using plotly_resampler with manual mode to plot hundred of thousands points in a plotly graph. I want the user to add or remove events from this plot. To add the events, it's quite simple, I have to call .add_trace(). But to remove the events 2 options are available. Either I use .visible = False or I transform the FigureResampler to a json format and remove the last data value.
But when I do this, the json format loses all the points that are not plotted in the graph. So I can lost 80-90% of my points and I can't get them back.
Is there a solution to erase a trace from a FigureResampler without losing all points and losing the state of 'FigureResampler'?
I should add that I would like to avoid .visible = False for the sake of performance. Thank you!
FigureResampler only renders aggregated data of the high-frequency traces.
This is achieved by storing this aggregated data in plotly's default data property and storing the raw, high-frequency, data in the (non-plotly) _hf_data property.
As such, when the plotly's to_json() is invoked, only the aggregated data, stored within the data property, will be serialized into the .json file. So there is no convenient method to store the high frequency data into a .json file. Also remark that .json is an inefficient manner to store (large amounts of) data as e.g. floats will be encoded as strings.
However, FigureResampler figures can be serialized into pickle objects (which stores the data-as-is (i.e. in binary format). Maybe you could use this format to save your FigureResampler figures?
trace_index=1# specify the trace index# delete the `hf_data` entryfig._hf_data.pop(fig.data[trace_index].uid) # the hf_data is a dict keyed by trace uid# delete the trace itself in the `data` listfig.data[1].visible=Falsefig.data[1].x= []
fig.data[1].y= []
Regarding removing a data-value (e.g. the last value) from a trace
Could you provide me with a minimal code example regarding your use-case?
I hope this helps you any further!
Kind regards,
Jonas
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I am using plotly_resampler with manual mode to plot hundred of thousands points in a plotly graph. I want the user to add or remove events from this plot. To add the events, it's quite simple, I have to call .add_trace(). But to remove the events 2 options are available. Either I use .visible = False or I transform the FigureResampler to a json format and remove the last data value.
But when I do this, the json format loses all the points that are not plotted in the graph. So I can lost 80-90% of my points and I can't get them back.
Is there a solution to erase a trace from a FigureResampler without losing all points and losing the state of 'FigureResampler'?
I should add that I would like to avoid .visible = False for the sake of performance. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions