Custom Slider in Python - Manipulating NetworkX graph

Is it posible to manipulate variables in by using a Plotly slider?
I want to increase the number of nodes by using a slider.

Yes, absolutely. If β€˜graph’ is the id of your networkx graph and β€˜slider’ is the id of your slider it would look something like:

@app.callback(
Output("graph", "figure"), 
Input("slider", "value"),
State("graph", "figure")
)
def update_graph(slider_value, figure):
  # apply some change to figure based on slider value
  return figure

Any time the slider value is changed this callback will be executed and the figure will be updated.

1 Like