0

I am displaying data using a matplotlib scatterplot:

fig = plt.figure()
ax = fig.add_subplot(111)
sp = ax.scatter(x,y,c=c)

My data updates periodically, however, and I would like to update the plot without having to clear the figure and plot again; I would like to simply "update" the data of the existing plot, but I haven't had any luck finding out how to do this. Is this possible?

EDIT: I should have included that I am also trying to update the color of the points (c in the above code). I am making a scatter plot of a large collection of (x,y,c) data where c is the color/threshold and the user can select the threshold above which the points are displayed and below which they are not. sp.set_offsets(np.c_[x,y]) looks like it works to update the points being displayed (thanks, @ImportanceOfBeingErnest), but I also need to update the c values.

  • that's exactly my problem - i want to replace the data without clearing the figure. You can do this in matlab via `sp.set_xdata(x_new); sp.set_ydata(y_new)` but I haven't found an equivalent functionality in matplotlib – James Roberts Jul 13 '18 at 00:03
  • The duplicate is the first google result when searching for "matplotlib update scatter". Isn't it much harder to write a complete question here than simply search for the result? – ImportanceOfBeingErnest Jul 13 '18 at 00:12

0 Answers0