@@ -1515,16 +1515,15 @@ class VertexSelector:
15151515 Derived classes should override the `process_selected` method to do
15161516 something with the picks.
15171517
1518- Here is an example which highlights the selected verts with red
1519- circles::
1518+ Here is an example which highlights the selected verts with red circles::
15201519
15211520 import numpy as np
15221521 import matplotlib.pyplot as plt
15231522 import matplotlib.lines as lines
15241523
15251524 class HighlightSelected(lines.VertexSelector):
15261525 def __init__(self, line, fmt='ro', **kwargs):
1527- lines.VertexSelector. __init__(self, line)
1526+ super(). __init__(line)
15281527 self.markers, = self.axes.plot([], [], fmt, **kwargs)
15291528
15301529 def process_selected(self, ind, xs, ys):
@@ -1537,27 +1536,29 @@ def process_selected(self, ind, xs, ys):
15371536
15381537 selector = HighlightSelected(line)
15391538 plt.show()
1540-
15411539 """
1540+
15421541 def __init__ (self , line ):
15431542 """
1544- Initialize the class with a `.Line2D`. The line should already be
1545- added to an `~.axes.Axes` and should have the picker property set.
1543+ Parameters
1544+ ----------
1545+ line : `.Line2D`
1546+ The line must already have been added to an `~.axes.Axes` and must
1547+ have its picker property set.
15461548 """
15471549 if line .axes is None :
15481550 raise RuntimeError ('You must first add the line to the Axes' )
1549-
15501551 if line .get_picker () is None :
15511552 raise RuntimeError ('You must first set the picker property '
15521553 'of the line' )
1553-
15541554 self .axes = line .axes
15551555 self .line = line
1556- self .canvas = self .axes .figure .canvas
1557- self .cid = self .canvas .mpl_connect ('pick_event' , self .onpick )
1558-
1556+ self .cid = self .canvas .callbacks ._connect_picklable (
1557+ 'pick_event' , self .onpick )
15591558 self .ind = set ()
15601559
1560+ canvas = property (lambda self : self .axes .figure .canvas )
1561+
15611562 def process_selected (self , ind , xs , ys ):
15621563 """
15631564 Default "do nothing" implementation of the `process_selected` method.
0 commit comments