99from pylab import *
1010import sys
1111
12+ rcParams ['legend.loc' ] = 'best'
1213
1314N = 100
1415x = arange (N )
@@ -17,55 +18,55 @@ def fig_1():
1718 figure (1 )
1819 t = arange (0 , 40.0 * pi , 0.1 )
1920 l , = plot (t , 100 * sin (t ), 'r' , label = 'sine' )
20- legend (loc = 'best' )
21+ legend ()
2122
2223def fig_2 ():
2324 figure (2 )
2425 plot (x , 'o' , label = 'x=y' )
25- legend (loc = 'best' )
26+ legend ()
2627
2728def fig_3 ():
2829 figure (3 )
2930 plot (x , - x , 'o' , label = 'x= -y' )
30- legend (loc = 'best' )
31+ legend ()
3132
3233def fig_4 ():
3334 figure (4 )
3435 plot (x , ones (len (x )), 'o' , label = 'y=1' )
3536 plot (x , - ones (len (x )), 'o' , label = 'y=-1' )
36- legend (loc = 'best' )
37+ legend ()
3738
3839def fig_5 ():
3940 figure (5 )
4041 n , bins , patches = hist (randn (1000 ), 40 , normed = 1 )
4142 l , = plot (bins , normpdf (bins , 0.0 , 1.0 ), 'r--' , label = 'fit' , linewidth = 3 )
42- legend ([l , patches [0 ]], ['fit' , 'hist' ], loc = 'best' )
43+ legend ([l , patches [0 ]], ['fit' , 'hist' ])
4344
4445def fig_6 ():
4546 figure (6 )
4647 plot (x , 50 - x , 'o' , label = 'y=1' )
4748 plot (x , x - 50 , 'o' , label = 'y=-1' )
48- legend (loc = 'best' )
49+ legend ()
4950
5051def fig_7 ():
5152 figure (7 )
5253 xx = x - (N / 2.0 )
5354 plot (xx , (xx * xx )- 1225 , 'bo' , label = '$y=x^2$' )
5455 plot (xx , 25 * xx , 'go' , label = '$y=25x$' )
5556 plot (xx , - 25 * xx , 'mo' , label = '$y=-25x$' )
56- legend (loc = 'best' )
57+ legend ()
5758
5859def fig_8 ():
5960 figure (8 )
6061 b1 = bar (x , x , color = 'm' )
6162 b2 = bar (x , x [::- 1 ], color = 'g' )
62- legend ([b1 [0 ], b2 [0 ]], ['up' , 'down' ], loc = 'best' )
63+ legend ([b1 [0 ], b2 [0 ]], ['up' , 'down' ])
6364
6465def fig_9 ():
6566 figure (9 )
6667 b1 = bar (x , - x )
6768 b2 = bar (x , - x [::- 1 ], color = 'r' )
68- legend ([b1 [0 ], b2 [0 ]], ['down' , 'up' ], loc = 'best' )
69+ legend ([b1 [0 ], b2 [0 ]], ['down' , 'up' ])
6970
7071def fig_10 ():
7172 figure (10 )
@@ -74,8 +75,7 @@ def fig_10():
7475 b3 = bar (x , - x , bottom = 100 )
7576 b4 = bar (x , - x [::- 1 ], bottom = 100 , color = 'r' )
7677 legend ([b1 [0 ], b2 [0 ], b3 [0 ], b4 [0 ]], ['bottom right' , 'bottom left' ,
77- 'top left' , 'top right' ],
78- loc = 'best' )
78+ 'top left' , 'top right' ])
7979
8080if __name__ == '__main__' :
8181 nfigs = 10
0 commit comments