| 28 | |
| 29 | |
| 30 | class ProcessPlotter: |
| 31 | def __init__(self): |
| 32 | self.x = [] |
| 33 | self.y = [] |
| 34 | |
| 35 | def terminate(self): |
| 36 | plt.close('all') |
| 37 | |
| 38 | def call_back(self): |
| 39 | while self.pipe.poll(): |
| 40 | command = self.pipe.recv() |
| 41 | if command is None: |
| 42 | self.terminate() |
| 43 | return False |
| 44 | else: |
| 45 | self.x.append(command[0]) |
| 46 | self.y.append(command[1]) |
| 47 | self.ax.plot(self.x, self.y, 'ro') |
| 48 | self.fig.canvas.draw() |
| 49 | return True |
| 50 | |
| 51 | def __call__(self, pipe): |
| 52 | print('starting plotter...') |
| 53 | |
| 54 | self.pipe = pipe |
| 55 | self.fig, self.ax = plt.subplots() |
| 56 | timer = self.fig.canvas.new_timer(interval=1000) |
| 57 | timer.add_callback(self.call_back) |
| 58 | timer.start() |
| 59 | |
| 60 | print('...done') |
| 61 | plt.show() |
| 62 | |
| 63 | # %% |
| 64 | # |
no outgoing calls
no test coverage detected
searching dependent graphs…