Created
October 5, 2022 16:43
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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