@@ -1515,16 +1515,15 @@ class VertexSelector:
1515
1515
Derived classes should override the `process_selected` method to do
1516
1516
something with the picks.
1517
1517
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::
1520
1519
1521
1520
import numpy as np
1522
1521
import matplotlib.pyplot as plt
1523
1522
import matplotlib.lines as lines
1524
1523
1525
1524
class HighlightSelected(lines.VertexSelector):
1526
1525
def __init__(self, line, fmt='ro', **kwargs):
1527
- lines.VertexSelector. __init__(self, line)
1526
+ super(). __init__(line)
1528
1527
self.markers, = self.axes.plot([], [], fmt, **kwargs)
1529
1528
1530
1529
def process_selected(self, ind, xs, ys):
@@ -1537,27 +1536,29 @@ def process_selected(self, ind, xs, ys):
1537
1536
1538
1537
selector = HighlightSelected(line)
1539
1538
plt.show()
1540
-
1541
1539
"""
1540
+
1542
1541
def __init__ (self , line ):
1543
1542
"""
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.
1546
1548
"""
1547
1549
if line .axes is None :
1548
1550
raise RuntimeError ('You must first add the line to the Axes' )
1549
-
1550
1551
if line .get_picker () is None :
1551
1552
raise RuntimeError ('You must first set the picker property '
1552
1553
'of the line' )
1553
-
1554
1554
self .axes = line .axes
1555
1555
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 )
1559
1558
self .ind = set ()
1560
1559
1560
+ canvas = property (lambda self : self .axes .figure .canvas )
1561
+
1561
1562
def process_selected (self , ind , xs , ys ):
1562
1563
"""
1563
1564
Default "do nothing" implementation of the `process_selected` method.
0 commit comments