Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot(self):
- import matplotlib.pyplot as plt
- plt.ion()
- self.fig,self.axis = plt.subplots()
- self.line, = plt.plot([1,2],[10,10],color = '#A9F5D0', label="# Monitor Peers", marker='o', ls='None', markeredgecolor='#A9F5D0', animated=True)
- plt.axis([0, 100, 0, 101])
- self.fig.canvas.draw()
- self.line.set_xdata(self.x)
- def update(self,y):
- self.line.set_ydata(y)
- self.axis.draw_artist(self.line)
- self.fig.canvas.blit(self.axis.bbox)
- self.fig.canvas.flush_events()
- def store(self):
- drawing_log_file = open("test.txt", "w", 1)
- drawing_log_file.write(str(self.n)+'n')
- # Configuration in the first line
- while True:
- time.sleep(0.1)
- y = np.random.randint(0,100,self.n)
- # f.write("n".join(map(lambda x: str(x), mylist)))
- drawing_log_file.write(" ".join(map(str, y))+'n')
- drawing_log_file.write("Bye")
- drawing_log_file.close()
- def draw(self):
- self.plot()
- time.sleep(2)
- file = open("test.txt","r")
- while True:
- time.sleep(2)
- line = file.readline()
- y = line.strip().split(" ", self.n)
- self.update(y)
- def run(self):
- Process(target=self.store).start()
- time.sleep(5)
- p = Process(target=self.draw)
- p.start()
- fire.Fire(Simulation)`
Add Comment
Please, Sign In to add comment