0

I have a plot (density plot) from data, used as a background. I add a line or a curve over it, and need to change position of that curve with mouse click.

How can I do that in Python using matplotlib?

Building the plot take time, so I want not to redraw the whole plot, only a simple curve or a line.

Alvaro Silvino
  • 9,441
  • 12
  • 52
  • 80
jss
  • 203
  • 1
  • 3
  • 7

1 Answers1

0

I found similar question. To update the curve the ydata (and xdata if different) need to be updated.

1) assign a handle to the plot with the ydata of your curve

self.h,=self.axes.plot(data,"-g")

2) update the the ydata with your handle

self.h.set_ydata(newdata)
Community
  • 1
  • 1
jss
  • 203
  • 1
  • 3
  • 7