Dynamically Adding A Vertical Line To Matplotlib Plot
I'm trying to add vertical lines to a matplotlib plot dynmically when a user clicks on a particular point. import matplotlib.pyplot as plt import matplotlib.dates as mdate class
Solution 1:
You need to update the canvas drawing (self.fig.canvas.draw()
):
def onpick(self,event):
x = event.mouseevent.xdata
y = event.mouseevent.ydata
L = self.ax.axvline(x=x)
self.fig.canvas.draw()
Post a Comment for "Dynamically Adding A Vertical Line To Matplotlib Plot"