File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import matplotlib .collections as mcollections
1313from matplotlib .legend_handler import HandlerTuple
1414import matplotlib .legend as mlegend
15+ from matplotlib .cbook .deprecation import MatplotlibDeprecationWarning
1516
1617
1718def test_legend_ordereddict ():
@@ -511,3 +512,30 @@ def test_legend_title_fontsize():
511512 ax .plot (range (10 ))
512513 leg = ax .legend (title = 'Aardvark' , title_fontsize = 22 )
513514 assert leg .get_title ().get_fontsize () == 22
515+
516+
517+ def test_get_set_draggable ():
518+ legend = plt .legend ()
519+ assert not legend .get_draggable ()
520+ legend .set_draggable (True )
521+ assert legend .get_draggable ()
522+ legend .set_draggable (False )
523+ assert not legend .get_draggable ()
524+
525+
526+ def test_draggable ():
527+ legend = plt .legend ()
528+ with pytest .warns (MatplotlibDeprecationWarning ):
529+ legend .draggable (True )
530+ assert legend .get_draggable ()
531+ with pytest .warns (MatplotlibDeprecationWarning ):
532+ legend .draggable (False )
533+ assert not legend .get_draggable ()
534+
535+ # test toggle
536+ with pytest .warns (MatplotlibDeprecationWarning ):
537+ legend .draggable ()
538+ assert legend .get_draggable ()
539+ with pytest .warns (MatplotlibDeprecationWarning ):
540+ legend .draggable ()
541+ assert not legend .get_draggable ()
You can’t perform that action at this time.
0 commit comments