Skip to content

Instantly share code, notes, and snippets.

@Miladiouss
Created October 5, 2022 16:43
Show Gist options
  • Save Miladiouss/1cdc645fb11de5282f63044db208bc6e to your computer and use it in GitHub Desktop.
Save Miladiouss/1cdc645fb11de5282f63044db208bc6e to your computer and use it in GitHub Desktop.
Example of dynamic data visualization with Plotly where more data points are gradually added.
import plotly.graph_objects as go
from time import sleep
import numpy as np
fig = go.FigureWidget()
# Display in Jupyter:
display(fig)
sleep(.25)
fig.add_trace(go.Scatter(x=[0], y=[0]))
for x in range(200):
fig.data[0].x = np.concatenate([fig.data[0].x, [x]])
fig.data[0].y = np.concatenate([fig.data[0].y, [fig.data[0].y[-1] + np.random.uniform(-.1, +.1)]])
sleep(.001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment