I am plotting data points in 3D from with a code that looks something like that:
import plotly.graph_objects as go
import pandas as pd
# Sample DataFrame
df_ids_plot = pd.DataFrame({
'x': [1, 2, 3, 4, 5],
'y': [2, 3, 4, 5, 6],
'z': [3, 4, 5, 6, 7],
'weight': [1, 3, 5, 7, 9]
})
# Create initial figure
fig = go.Figure()
# Add scatter plot
scatter = fig.add_trace(go.Scatter3d(
x=df_ids_plot['x'],
y=df_ids_plot['y'],
z=df_ids_plot['z'],
mode='markers',
))
fig.show()
What I want to do next is to implement a slider and use this slider to throw away data points from the plot (turn their visibility off) when the value of the slider that I set gets larger than the weight
of the data points. E.g. when I set the slider to 6 I want all data points with weight
<6 to become invisible in the plot. I looked through the slider documentation, but I didn’t find how to do this.
Optionally, it would be nice if I could use a range slider and restrict with it the min and max value of data points simultaneously, e.g. set the range slider to min_value=4, max_value=6 and then only data points get displayed who’s weight is within the range 4<weight<6. Thx for advice how to do this!