| 1 | diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py |
| 2 | --- a/lib/matplotlib/legend.py |
| 3 | +++ b/lib/matplotlib/legend.py |
| 4 | @@ -286,6 +286,9 @@ def _update_bbox_to_anchor(self, loc_in_canvas): |
| 5 | The custom dictionary mapping instances or types to a legend |
| 6 | handler. This *handler_map* updates the default handler map |
| 7 | found at `matplotlib.legend.Legend.get_legend_handler_map`. |
| 8 | + |
| 9 | +draggable : bool, default: False |
| 10 | + Whether the legend can be dragged with the mouse. |
| 11 | """) |
| 12 | |
| 13 | |
| 14 | @@ -342,7 +345,8 @@ def __init__( |
| 15 | title_fontproperties=None, # properties for the legend title |
| 16 | alignment="center", # control the alignment within the legend box |
| 17 | *, |
| 18 | - ncol=1 # synonym for ncols (backward compatibility) |
| 19 | + ncol=1, # synonym for ncols (backward compatibility) |
| 20 | + draggable=False # whether the legend can be dragged with the mouse |
| 21 | ): |
| 22 | """ |
| 23 | Parameters |
| 24 | @@ -537,7 +541,9 @@ def val_or_rc(val, rc_name): |
| 25 | title_prop_fp.set_size(title_fontsize) |
| 26 | |
| 27 | self.set_title(title, prop=title_prop_fp) |
| 28 | + |
| 29 | self._draggable = None |
| 30 | + self.set_draggable(state=draggable) |
| 31 | |
| 32 | # set the text color |
| 33 | |