import matplotlib.pyplot as plt class Graph: def __init__(self, **kwargs): self.f = plt.figure() self.ax = self.f.add_subplot(111) self.line = None def draw_variable(self, x, y): self.x = x self.y = y self.ax.scatter(x, y) plt.ion() plt.show() def draw_line(self, x, y): if self.line is not None: self.line.remove() self.line = plt.Line2D(x, y, color='r') self.ax.add_line(self.line) plt.draw() plt.pause(0.000000001)