<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:rgb(0,0,0)">It worked. However, I was looking for in one graph but here it's producing n no of graphs. can we make it in the graph ?</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:rgb(0,0,0)">partha</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:#000000"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 31 May 2019 at 21:10, Scott Lasley <<a href="mailto:selasley@icloud.com">selasley@icloud.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Try using plt.pause instead of time.sleep.  This may do what you want<br>
<br>
import matplotlib.pyplot as plt<br>
from random import randint<br>
<br>
numbers = [0]*5<br>
# draw the initial points<br>
oldlines = plt.plot(range(1, 6), numbers, 'o', c='r')<br>
plt.pause(5)<br>
for i in range(5):<br>
    numbers[i] = randint(0,100)<br>
    # remove the previously plotted lines before drawing the new ones<br>
    oldlines[0].remove()<br>
    oldlines = plt.plot(range(1, 6), numbers, 'o', c='r')<br>
    plt.pause(5)<br>
<br>
<br>
<br>
> On May 31, 2019, at 5:07 AM, Partha Sinha <<a href="mailto:pnsinha68@gmail.com" target="_blank">pnsinha68@gmail.com</a>> wrote:<br>
> <br>
> I want help on graph<br>
> I need to plot numbers one by one (lets say after interval of 5 sec) but all in the same graph. How to do ?<br>
> My code is below<br>
> <br>
> <br>
> import time    <br>
> import matplotlib.pyplot as plt<br>
> import numpy as np<br>
> from random import randint<br>
> i = 1<br>
> numbers = [0]*5<br>
> while i < 5:<br>
>      numbers[i] = randint(0,100)<br>
>      plt.plot(np.arange(1,6),numbers, 'o')<br>
>      i += 1<br>
>      matplotlib.pyplot.draw()<br>
>      time.sleep(5)<br>
> _______________________________________________<br>
> Matplotlib-users mailing list<br>
> <a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
<br>
</blockquote></div>