Hi,
I have an array of integers. I would like to plot the elements of array with some delays in the plot. How should I do that in python ?
The triple backticks approach you used is just fine.
import random
import time
import matplotlib.pyplot as plt
index = 0
while index < 100 :
y = random.randint(0,100)
index = index +1
time.sleep(0.5) # Sleep for 500 milliseconds
print("Random Number " + str(index) + " = " + str(y))
plt.scatter(index, y)
plt.ylabel('some numbers')
plt.show()
The script above works for me. Do you get any error messages?
I did comment out the time.sleep(0.5) line, which means it takes at
least 50s to generate the data overall.
Cheers,
Cameron Simpson cs@cskk.id.au