Set whether the annotation is draggable with the mouse. Parameters ---------- state : bool or None - True or False: set the draggability. - None: toggle the draggability. use_blit : bool, default: False Use blitting for fa
(self, state=None, use_blit=False)
| 1811 | return True |
| 1812 | |
| 1813 | def draggable(self, state=None, use_blit=False): |
| 1814 | """ |
| 1815 | Set whether the annotation is draggable with the mouse. |
| 1816 | |
| 1817 | Parameters |
| 1818 | ---------- |
| 1819 | state : bool or None |
| 1820 | - True or False: set the draggability. |
| 1821 | - None: toggle the draggability. |
| 1822 | use_blit : bool, default: False |
| 1823 | Use blitting for faster image composition. For details see |
| 1824 | :ref:`func-animation`. |
| 1825 | |
| 1826 | Returns |
| 1827 | ------- |
| 1828 | DraggableAnnotation or None |
| 1829 | If the annotation is draggable, the corresponding |
| 1830 | `.DraggableAnnotation` helper is returned. |
| 1831 | """ |
| 1832 | from matplotlib.offsetbox import DraggableAnnotation |
| 1833 | is_draggable = self._draggable is not None |
| 1834 | |
| 1835 | # if state is None we'll toggle |
| 1836 | if state is None: |
| 1837 | state = not is_draggable |
| 1838 | |
| 1839 | if state: |
| 1840 | if self._draggable is None: |
| 1841 | self._draggable = DraggableAnnotation(self, use_blit) |
| 1842 | else: |
| 1843 | if self._draggable is not None: |
| 1844 | self._draggable.disconnect() |
| 1845 | self._draggable = None |
| 1846 | |
| 1847 | return self._draggable |
| 1848 | |
| 1849 | |
| 1850 | class Annotation(Text, _AnnotationBase): |