# How to plot real time numbers from an array

**URL:** <https://discuss.python.org/t/how-to-plot-real-time-numbers-from-an-array/10137>\
**Category:** Python Help\
**Created:** [August 13, 2021, 10:55am UTC](https://discuss.python.org/t/how-to-plot-real-time-numbers-from-an-array/10137 "2021-08-13T10:55:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joni](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@Joni](https://discuss.python.org/u/Joni)\
**Post date:** [August 13, 2021, 10:55am UTC](https://discuss.python.org/t/how-to-plot-real-time-numbers-from-an-array/10137/1 "2021-08-13T10:55:08Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![cameron](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cameron/32/2658_2.png) [@cameron](https://discuss.python.org/u/cameron)\
**Post date:** [August 13, 2021, 11:22pm UTC](https://discuss.python.org/t/how-to-plot-real-time-numbers-from-an-array/10137/2 "2021-08-13T23:22:44Z")

</div>

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](mailto:cs@cskk.id.au)
