[Matplotlib-users] plot

Partha Sinha pnsinha68 at gmail.com
Fri May 31 12:11:27 EDT 2019


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 ?
partha


On Fri, 31 May 2019 at 21:10, Scott Lasley <selasley at icloud.com> wrote:

> Try using plt.pause instead of time.sleep.  This may do what you want
>
> import matplotlib.pyplot as plt
> from random import randint
>
> numbers = [0]*5
> # draw the initial points
> oldlines = plt.plot(range(1, 6), numbers, 'o', c='r')
> plt.pause(5)
> for i in range(5):
>     numbers[i] = randint(0,100)
>     # remove the previously plotted lines before drawing the new ones
>     oldlines[0].remove()
>     oldlines = plt.plot(range(1, 6), numbers, 'o', c='r')
>     plt.pause(5)
>
>
>
> > On May 31, 2019, at 5:07 AM, Partha Sinha <pnsinha68 at gmail.com> wrote:
> >
> > I want help on graph
> > I need to plot numbers one by one (lets say after interval of 5 sec) but
> all in the same graph. How to do ?
> > My code is below
> >
> >
> > import time
> > import matplotlib.pyplot as plt
> > import numpy as np
> > from random import randint
> > i = 1
> > numbers = [0]*5
> > while i < 5:
> >      numbers[i] = randint(0,100)
> >      plt.plot(np.arange(1,6),numbers, 'o')
> >      i += 1
> >      matplotlib.pyplot.draw()
> >      time.sleep(5)
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users at python.org
> > https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190531/8b88ed53/attachment.html>


More information about the Matplotlib-users mailing list