Problem in real time matplotlib plotting

0 votes

Here, In my code x axis='Time' and y='Random Number'. so, I just want to plot graph with these variables using real time matplotlib.

import matplotlib.pyplot as plt
import datetime
import numpy as np
import time

def GetRandomIntNumber(Data):
   timerCounter=0
   x=[]
   y=[]
   while timerCounter < 5000:
       NewNumber = Data * np.random.randomint(5)
       x.append(datetime.datetime.now())
       y.append(NewNumber)
       plt.plot(x,y)
       plt.show()
       time.sleep(10)

a = 10
GetRandomIntNumber(a)
May 24, 2019 in Python by Sucheta
1,131 views

1 answer to this question.

0 votes

Hi Sucheta,

The error I can see in your code that is because there is no function called randomint .

You can check out this code to remove your error.

import matplotlib.pyplot as plt
import datetime
import numpy as np
import time

def GetRandomIntNumber(Data):
   timerCounter=0
   x=[]
   y=[]
   while timerCounter < 5000:
       NewNumber = Data * np.random.randint(5)
       x.append(datetime.datetime.now())
       y.append(NewNumber)
       plt.plot(x,y)
       plt.show()
       time.sleep(10)

a = 10
GetRandomIntNumber(a)

I hope it will help you, just let me know if it works.

answered May 24, 2019 by sampriti
• 1,120 points

Related Questions In Python

0 votes
1 answer

Create time lag in Python

import time time.sleep(10) READ MORE

answered May 2, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,561 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8, 2019 in Python by rajesh
• 1,270 points
1,667 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,830 points
512 views
0 votes
1 answer

Get the Current time in Python

To get the current date and time ...READ MORE

answered Oct 3, 2018 in Python by SDeb
• 13,300 points
477 views
0 votes
1 answer

Time delay in Python

The following code will delay it for ...READ MORE

answered Oct 4, 2018 in Python by SDeb
• 13,300 points
946 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,090 points
1,182 views
+1 vote
1 answer

How to handle Real-Time Matplotlib Plotting

To draw a continuous set of random ...READ MORE

answered Sep 26, 2018 in Python by Priyaj
• 58,090 points
15,692 views
0 votes
1 answer

How to increase plt.title font size?

Try the following : import matplotlib.pyplot as plt plt.figtext(.5,.9,'Temperature', ...READ MORE

answered Feb 11, 2019 in Python by SDeb
• 13,300 points
873 views
0 votes
1 answer

How to drop missing value in python data-frame?

Hi Sarada,  I understand you are having problems with ...READ MORE

answered May 28, 2019 in Python by sampriti
• 1,120 points
1,145 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP