Helper to simulate a mouse drag operation. Parameters ---------- tool : `~matplotlib.widgets.Widget` start : [float, float] Starting point in data coordinates. end : [float, float] End point in data coordinates. key : None or str An optional key
(tool, start, end, key=None)
| 95 | |
| 96 | |
| 97 | def click_and_drag(tool, start, end, key=None): |
| 98 | """ |
| 99 | Helper to simulate a mouse drag operation. |
| 100 | |
| 101 | Parameters |
| 102 | ---------- |
| 103 | tool : `~matplotlib.widgets.Widget` |
| 104 | start : [float, float] |
| 105 | Starting point in data coordinates. |
| 106 | end : [float, float] |
| 107 | End point in data coordinates. |
| 108 | key : None or str |
| 109 | An optional key that is pressed during the whole operation |
| 110 | (see also `.KeyEvent`). |
| 111 | """ |
| 112 | ax = tool.ax |
| 113 | if key is not None: # Press key |
| 114 | KeyEvent._from_ax_coords("key_press_event", ax, start, key)._process() |
| 115 | # Click, move, and release mouse |
| 116 | MouseEvent._from_ax_coords("button_press_event", ax, start, 1)._process() |
| 117 | MouseEvent._from_ax_coords("motion_notify_event", ax, end, 1)._process() |
| 118 | MouseEvent._from_ax_coords("button_release_event", ax, end, 1)._process() |
| 119 | if key is not None: # Release key |
| 120 | KeyEvent._from_ax_coords("key_release_event", ax, end, key)._process() |
searching dependent graphs…