SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import streamlit as st
  4. import time
  5.  
  6. fig, ax = plt.subplots()
  7.  
  8. max_x = 5
  9. max_rand = 10
  10.  
  11. x = np.arange(0, max_x)
  12. ax.set_ylim(0, max_rand)
  13. line, = ax.plot(x, np.random.randint(0, max_rand, max_x))
  14. the_plot = st.pyplot(plt)
  15.  
  16. def init():  # give a clean slate to start
  17.     line.set_ydata([np.nan] * len(x))
  18.  
  19. def animate(i):  # update the y values (every 1000ms)
  20.     line.set_ydata(np.random.randint(0, max_rand, max_x))
  21.     the_plot.pyplot(plt)
  22.  
  23. init()
  24. for i in range(100):
  25.     animate(i)
  26.     time.sleep(0.1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top