Hi @darynella2001
You could make use of the sleep method from the time module together with a for loop to iteratively update the plot every N seconds (e.g. time.sleep(1))
Here are some relevant posts to get you started:
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Hi, I am not sure how to “call chart on that frame”, would u be able to show a code snippet?
this is my current code for st.line_chart for reloading the chart based on new updates of rows.
cpu_chart = st.line_chart(df height=250)
for i in range(100):
cpu_chart.add_rows(df2)
For altair, a code like this wouldnt work as it will create a new frame every iteration.
numpy as np
import altair as alt
df = pd.DataFrame(
np.random.randn(100, 3),
columns=['a', 'b', 'c'])
c = alt.Chart(d…
Hi @cristian.cotoi ! Welcome to the Streamlit community!
It is absolutely possible to animate matplotlib charts in Streamlit. I’ve modified your code in this gist :
import matplotlib.pyplot as plt
import numpy as np
import streamlit as st
import time
fig, ax = plt.subplots()
max_x = 5
max_rand = 10
x = np.arange(0, max_x)
ax.set_ylim(0, max_rand)
line, = ax.plot(x, np.random.randint(0, max_rand, max_x))
the_plot = st.pyplot(plt)
def init(): # give a clean slate to start
line.set_…
This blog also has an example that you can use a starter idea:
Hope these helps!