matplotlib.lines.VertexSelector#

classmatplotlib.lines.VertexSelector(line)[source]#

Bases:object

Manage the callbacks to maintain a list of selected vertices forLine2D.Derived classes should override theprocess_selected method to dosomething with the picks.

Here is an example which highlights the selected verts with red circles:

importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlib.linesaslinesclassHighlightSelected(lines.VertexSelector):def__init__(self,line,fmt='ro',**kwargs):super().__init__(line)self.markers,=self.axes.plot([],[],fmt,**kwargs)defprocess_selected(self,ind,xs,ys):self.markers.set_data(xs,ys)self.canvas.draw()fig,ax=plt.subplots()x,y=np.random.rand(2,30)line,=ax.plot(x,y,'bs-',picker=5)selector=HighlightSelected(line)plt.show()
Parameters:
lineLine2D

The line must already have been added to anAxes and musthave its picker property set.

propertycanvas#
onpick(event)[source]#

When the line is picked, update the set of selected indices.

process_selected(ind,xs,ys)[source]#

Default "do nothing" implementation of theprocess_selected method.

Parameters:
indlist of int

The indices of the selected vertices.

xs, ysarray-like

The coordinates of the selected vertices.