A pick event. This event is fired when the user picks a location on the canvas sufficiently close to an artist that has been made pickable with `.Artist.set_picker`. A PickEvent has a number of special attributes in addition to those defined by the parent `Event` class.
| 1446 | |
| 1447 | |
| 1448 | class PickEvent(Event): |
| 1449 | """ |
| 1450 | A pick event. |
| 1451 | |
| 1452 | This event is fired when the user picks a location on the canvas |
| 1453 | sufficiently close to an artist that has been made pickable with |
| 1454 | `.Artist.set_picker`. |
| 1455 | |
| 1456 | A PickEvent has a number of special attributes in addition to those defined |
| 1457 | by the parent `Event` class. |
| 1458 | |
| 1459 | Attributes |
| 1460 | ---------- |
| 1461 | mouseevent : `MouseEvent` |
| 1462 | The mouse event that generated the pick. |
| 1463 | artist : `~matplotlib.artist.Artist` |
| 1464 | The picked artist. Note that artists are not pickable by default |
| 1465 | (see `.Artist.set_picker`). |
| 1466 | other |
| 1467 | Additional attributes may be present depending on the type of the |
| 1468 | picked object; e.g., a `.Line2D` pick may define different extra |
| 1469 | attributes than a `.PatchCollection` pick. |
| 1470 | |
| 1471 | Examples |
| 1472 | -------- |
| 1473 | Bind a function ``on_pick()`` to pick events, that prints the coordinates |
| 1474 | of the picked data point:: |
| 1475 | |
| 1476 | ax.plot(np.rand(100), 'o', picker=5) # 5 points tolerance |
| 1477 | |
| 1478 | def on_pick(event): |
| 1479 | line = event.artist |
| 1480 | xdata, ydata = line.get_data() |
| 1481 | ind = event.ind |
| 1482 | print(f'on pick line: {xdata[ind]:.3f}, {ydata[ind]:.3f}') |
| 1483 | |
| 1484 | cid = fig.canvas.mpl_connect('pick_event', on_pick) |
| 1485 | """ |
| 1486 | |
| 1487 | def __init__(self, name, canvas, mouseevent, artist, |
| 1488 | guiEvent=None, **kwargs): |
| 1489 | if guiEvent is None: |
| 1490 | guiEvent = mouseevent.guiEvent |
| 1491 | super().__init__(name, canvas, guiEvent) |
| 1492 | self.mouseevent = mouseevent |
| 1493 | self.artist = artist |
| 1494 | self.__dict__.update(kwargs) |
| 1495 | |
| 1496 | |
| 1497 | class KeyEvent(LocationEvent): |
no outgoing calls
no test coverage detected
searching dependent graphs…