11import numpy as np
22
3- from matplotlib .testing .decorators import image_comparison , knownfailureif
3+ from matplotlib .testing .decorators import image_comparison
44import matplotlib .pyplot as plt
5- from nose .tools import assert_raises
6- from numpy .testing import assert_array_equal
5+
76
87@image_comparison (baseline_images = ['legend_auto1' ], tol = 1.5e-3 , remove_text = True )
98def test_legend_auto1 ():
@@ -15,6 +14,7 @@ def test_legend_auto1():
1514 ax .plot (x , x - 50 , 'o' , label = 'y=-1' )
1615 ax .legend (loc = 0 )
1716
17+
1818@image_comparison (baseline_images = ['legend_auto2' ], remove_text = True )
1919def test_legend_auto2 ():
2020 'Test automatic legend placement'
@@ -24,3 +24,15 @@ def test_legend_auto2():
2424 b1 = ax .bar (x , x , color = 'm' )
2525 b2 = ax .bar (x , x [::- 1 ], color = 'g' )
2626 ax .legend ([b1 [0 ], b2 [0 ]], ['up' , 'down' ], loc = 0 )
27+
28+
29+ @image_comparison (baseline_images = ['legend_various_labels' ], remove_text = True )
30+ def test_various_labels ():
31+ # tests all sorts of label types
32+ fig = plt .figure ()
33+ ax = fig .add_subplot (121 )
34+ x = np .arange (100 )
35+ ax .plot (range (4 ), 'o' , label = 1 )
36+ ax .plot (np .linspace (4 , 4.1 ), 'o' , label = u'D\xe9 velopp\xe9 s' )
37+ ax .plot (range (4 , 1 , - 1 ), 'o' , label = '__nolegend__' )
38+ ax .legend (numpoints = 1 )
0 commit comments