My line collection does not seem to be clearing when I run code similar to the following example code:
def plot_from_ball(self, data, #more parameters):
self._plots.remove()
self._fig.canvas.draw_idle()
self._plots, = self._ax.plot(x,y, label = "ball", color = "white", marker="o")
for data in bigger_data
#irrelevant code
if #condition not relevant
self.home_plots, = self._ax.plot(data[x][i], data[y][i], color="red", marker="o")
else:
self.away_plots, = self._ax.plot(data[x][i], data[y][i], color="blue", marker="o")
return self._fig
Where self._plots is a collection, self._fig/self._ax are defined previously as
'fig, ax = pyt.subplots(figsize=(12,8))'
and later converted to object properties through:
self._fig, self._ax = fig, ax
, data is a list of tuples (irrelevant) & plots is my collection. The initial code to display the fig (I return it for use with Kivy Backend) works fine, however when I use the function again so i can redraw parts of the axis with new data (whilst others stay constant), the plots are instead added without the content of self._plots being removed from the screen.