Set SpanSelector to operate on a new Axes.
(self, ax, *, _props=None, _init=False)
| 2818 | self._active_handle = None |
| 2819 | |
| 2820 | def new_axes(self, ax, *, _props=None, _init=False): |
| 2821 | """Set SpanSelector to operate on a new Axes.""" |
| 2822 | reconnect = False |
| 2823 | if _init or self.canvas is not ax.get_figure(root=True).canvas: |
| 2824 | if self.canvas is not None: |
| 2825 | self.disconnect_events() |
| 2826 | reconnect = True |
| 2827 | self.ax = ax |
| 2828 | if reconnect: |
| 2829 | self.connect_default_events() |
| 2830 | |
| 2831 | # Reset |
| 2832 | self._selection_completed = False |
| 2833 | |
| 2834 | if self.direction == 'horizontal': |
| 2835 | trans = ax.get_xaxis_transform() |
| 2836 | w, h = 0, 1 |
| 2837 | else: |
| 2838 | trans = ax.get_yaxis_transform() |
| 2839 | w, h = 1, 0 |
| 2840 | rect_artist = Rectangle((0, 0), w, h, transform=trans, visible=False) |
| 2841 | if _props is not None: |
| 2842 | rect_artist.update(_props) |
| 2843 | elif self._selection_artist is not None: |
| 2844 | rect_artist.update_from(self._selection_artist) |
| 2845 | |
| 2846 | self.ax.add_patch(rect_artist) |
| 2847 | self._selection_artist = rect_artist |
| 2848 | |
| 2849 | def _setup_edge_handles(self, props): |
| 2850 | # Define initial position using the axis bounds to keep the same bounds |
no test coverage detected