16
16
from artist import Artist , setp
17
17
from axis import XAxis , YAxis
18
18
from cbook import iterable , is_string_like , flatten , enumerate , \
19
- allequal , dict_delall , popd , popall , silent_list , is_numlike , dedent
19
+ allequal , dict_delall , popall , silent_list , is_numlike , dedent
20
20
from collections import RegularPolyCollection , PolyCollection , LineCollection , \
21
21
QuadMesh , StarPolygonCollection , BrokenBarHCollection
22
22
from colors import colorConverter , Normalize , Colormap , \
@@ -203,16 +203,15 @@ def _get_next_cycle_color(self):
203
203
return color
204
204
205
205
def __call__ (self , * args , ** kwargs ):
206
- kwargs = kwargs .copy ()
207
206
208
207
if self .axes .xaxis is not None and self .axes .xaxis is not None :
209
- xunits = popd ( kwargs , 'xunits' , self .axes .xaxis .units )
210
- yunits = popd ( kwargs , 'yunits' , self .axes .yaxis .units )
208
+ xunits = kwargs . pop ( 'xunits' , self .axes .xaxis .units )
209
+ yunits = kwargs . pop ( 'yunits' , self .axes .yaxis .units )
211
210
if xunits != self .axes .xaxis .units :
212
211
self .axes .xaxis .set_units (xunits )
213
212
if yunits != self .axes .yaxis .units :
214
213
self .axes .yaxis .set_units (yunits )
215
-
214
+
216
215
ret = self ._grab_next_args (* args , ** kwargs )
217
216
return ret
218
217
@@ -238,7 +237,7 @@ def _xy_from_y(self, y):
238
237
if self .axes .yaxis is not None :
239
238
b = self .axes .yaxis .update_units (y )
240
239
if b : return arange (len (y )), y , False
241
-
240
+
242
241
y = ma .asarray (y )
243
242
if len (y .shape ) == 1 :
244
243
y = y [:,newaxis ]
@@ -249,12 +248,12 @@ def _xy_from_y(self, y):
249
248
return x ,y , True
250
249
251
250
def _xy_from_xy (self , x , y ):
252
- if self .axes .xaxis is not None and self .axes .yaxis is not None :
251
+ if self .axes .xaxis is not None and self .axes .yaxis is not None :
253
252
bx = self .axes .xaxis .update_units (x )
254
253
by = self .axes .yaxis .update_units (y )
255
254
# right now multicol is not supported if either x or y are
256
255
# unit enabled but this can be fixed..
257
- if bx or by : return x , y , False
256
+ if bx or by : return x , y , False
258
257
259
258
x = ma .asarray (x )
260
259
y = ma .asarray (y )
@@ -366,7 +365,6 @@ def makefill(x, y):
366
365
return ret
367
366
368
367
def _plot_3_args (self , tup3 , ** kwargs ):
369
- kwargs = kwargs .copy ()
370
368
ret = []
371
369
372
370
x , y , fmt = tup3
@@ -1046,7 +1044,7 @@ def add_collection(self, collection, autolim=False):
1046
1044
if autolim :
1047
1045
self .update_datalim (collection .get_verts (self .transData ))
1048
1046
1049
-
1047
+
1050
1048
def add_line (self , line ):
1051
1049
'Add a line to the list of plot lines'
1052
1050
self ._set_artist_props (line )
@@ -1068,7 +1066,7 @@ def _update_line_limits(self, line):
1068
1066
ydata = array ([y for x ,y in xys ])
1069
1067
1070
1068
self .update_datalim_numerix ( xdata , ydata )
1071
-
1069
+
1072
1070
1073
1071
def add_patch (self , p ):
1074
1072
"""
@@ -1081,7 +1079,7 @@ def add_patch(self, p):
1081
1079
p .set_clip_box (self .bbox )
1082
1080
self ._update_patch_limits (p )
1083
1081
self .patches .append (p )
1084
-
1082
+
1085
1083
def _update_patch_limits (self , p ):
1086
1084
'update the datalimits for patch p'
1087
1085
xys = self ._get_verts_in_data_coords (
@@ -1102,7 +1100,7 @@ def relim(self):
1102
1100
1103
1101
for p in self .patches :
1104
1102
self ._update_patch_limits (patch )
1105
-
1103
+
1106
1104
def update_datalim (self , xys ):
1107
1105
'Update the data lim bbox with seq of xy tups or equiv. 2-D array'
1108
1106
# if no data is set currently, the bbox will ignore its
@@ -1135,25 +1133,25 @@ def _get_verts_in_data_coords(self, trans, xys):
1135
1133
def _process_unit_info (self , xdata = None , ydata = None , kwargs = None ):
1136
1134
'look for unit kwargs and update the axis instances as necessary'
1137
1135
1138
- if self .xaxis is None or self .xaxis is None : return
1136
+ if self .xaxis is None or self .xaxis is None : return
1139
1137
1140
1138
1141
1139
if xdata is not None :
1142
1140
self .xaxis .update_units (xdata )
1143
1141
#print '_process updated xdata: units=%s, converter=%s'%(self.xaxis.units, self.xaxis.converter)
1144
1142
1145
1143
if ydata is not None :
1146
- self .yaxis .update_units (ydata )
1147
- #print '_process updated ydata: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
1144
+ self .yaxis .update_units (ydata )
1145
+ #print '_process updated ydata: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
1148
1146
1149
1147
# process kwargs 2nd since these will override default units
1150
1148
if kwargs is not None :
1151
- xunits = popd ( kwargs , 'xunits' , self .xaxis .units )
1149
+ xunits = kwargs . pop ( 'xunits' , self .xaxis .units )
1152
1150
if xunits != self .xaxis .units :
1153
1151
self .xaxis .set_units (xunits )
1154
1152
#print '_process updated xunits kws: units=%s, converter=%s'%(self.xaxis.units, self.xaxis.converter)
1155
1153
1156
- yunits = popd ( kwargs , 'yunits' , self .yaxis .units )
1154
+ yunits = kwargs . pop ( 'yunits' , self .yaxis .units )
1157
1155
if yunits != self .yaxis .units :
1158
1156
self .yaxis .set_units (yunits )
1159
1157
#print '_process updated yunits kws: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
@@ -2241,7 +2239,6 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
2241
2239
%(Polygon)s
2242
2240
"""
2243
2241
# convert y axis units
2244
- kwargs = kwargs .copy ()
2245
2242
2246
2243
trans = blend_xy_sep_transform ( self .transAxes , self .transData )
2247
2244
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
@@ -2283,7 +2280,6 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
2283
2280
%(Polygon)s
2284
2281
"""
2285
2282
# convert x axis units
2286
- kwargs = kwargs .copy ()
2287
2283
trans = blend_xy_sep_transform ( self .transData , self .transAxes )
2288
2284
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
2289
2285
p = Polygon (verts , ** kwargs )
@@ -2507,17 +2503,16 @@ def plot(self, *args, **kwargs):
2507
2503
information
2508
2504
"""
2509
2505
2510
- kwargs = kwargs .copy ()
2511
- scalex = popd (kwargs , 'scalex' , True )
2512
- scaley = popd (kwargs , 'scaley' , True )
2506
+ scalex = kwargs .pop ('scalex' , True )
2507
+ scaley = kwargs .pop ('scaley' , True )
2513
2508
2514
2509
if not self ._hold : self .cla ()
2515
2510
lines = []
2516
2511
2517
2512
for line in self ._get_lines (* args , ** kwargs ):
2518
2513
self .add_line (line )
2519
2514
lines .append (line )
2520
-
2515
+
2521
2516
2522
2517
self .autoscale_view (scalex = scalex , scaley = scaley )
2523
2518
return lines
@@ -2605,12 +2600,11 @@ def loglog(self, *args, **kwargs):
2605
2600
%(Line2D)s
2606
2601
"""
2607
2602
if not self ._hold : self .cla ()
2608
- kwargs = kwargs .copy ()
2609
- dx = {'basex' : popd (kwargs ,'basex' , 10 ),
2610
- 'subsx' : popd (kwargs ,'subsx' , None ),
2603
+ dx = {'basex' : kwargs .pop ('basex' , 10 ),
2604
+ 'subsx' : kwargs .pop ('subsx' , None ),
2611
2605
}
2612
- dy = {'basey' : popd ( kwargs , 'basey' , 10 ),
2613
- 'subsy' : popd ( kwargs , 'subsy' , None ),
2606
+ dy = {'basey' : kwargs . pop ( 'basey' , 10 ),
2607
+ 'subsy' : kwargs . pop ( 'subsy' , None ),
2614
2608
}
2615
2609
2616
2610
self .set_xscale ('log' , ** dx )
@@ -2645,9 +2639,8 @@ def semilogx(self, *args, **kwargs):
2645
2639
%(Line2D)s
2646
2640
"""
2647
2641
if not self ._hold : self .cla ()
2648
- kwargs = kwargs .copy ()
2649
- d = {'basex' : popd (kwargs , 'basex' , 10 ),
2650
- 'subsx' : popd (kwargs , 'subsx' , None ),
2642
+ d = {'basex' : kwargs .pop ('basex' , 10 ),
2643
+ 'subsx' : kwargs .pop ('subsx' , None ),
2651
2644
}
2652
2645
2653
2646
self .set_xscale ('log' , ** d )
@@ -2680,9 +2673,8 @@ def semilogy(self, *args, **kwargs):
2680
2673
2681
2674
"""
2682
2675
if not self ._hold : self .cla ()
2683
- kwargs = kwargs .copy ()
2684
- d = {'basey' : popd (kwargs ,'basey' , 10 ),
2685
- 'subsy' : popd (kwargs ,'subsy' , None ),
2676
+ d = {'basey' : kwargs .pop ('basey' , 10 ),
2677
+ 'subsy' : kwargs .pop ('subsy' , None ),
2686
2678
}
2687
2679
self .set_yscale ('log' , ** d )
2688
2680
b = self ._hold
@@ -2787,7 +2779,6 @@ def xcorr(self, x, y, normed=False, detrend=detrend_none, usevlines=False,
2787
2779
a = self .vlines (lags , [0 ], c , ** kwargs )
2788
2780
b = self .axhline (** kwargs )
2789
2781
else :
2790
- kwargs = kwargs .copy ()
2791
2782
kwargs .setdefault ('marker' , 'o' )
2792
2783
kwargs .setdefault ('linestyle' , 'None' )
2793
2784
a , = self .plot (lags , c , ** kwargs )
@@ -2859,7 +2850,6 @@ def legend(self, *args, **kwargs):
2859
2850
handletextsep = 0.02 # the space between the legend line and legend text
2860
2851
axespad = 0.02 # the border between the axes and legend edge
2861
2852
"""
2862
- kwargs = kwargs .copy ()
2863
2853
def get_handles ():
2864
2854
handles = self .lines
2865
2855
handles .extend (self .patches )
@@ -2876,13 +2866,13 @@ def get_handles():
2876
2866
if label != '_nolegend_' :
2877
2867
handles .append (line )
2878
2868
labels .append (label )
2879
- loc = popd ( kwargs , 'loc' , 1 )
2869
+ loc = kwargs . pop ( 'loc' , 1 )
2880
2870
2881
2871
elif len (args )== 1 :
2882
2872
# LABELS
2883
2873
labels = args [0 ]
2884
2874
handles = [h for h , label in zip (get_handles (), labels )]
2885
- loc = popd ( kwargs , 'loc' , 1 )
2875
+ loc = kwargs . pop ( 'loc' , 1 )
2886
2876
2887
2877
elif len (args )== 2 :
2888
2878
if is_string_like (args [1 ]) or isinstance (args [1 ], int ):
@@ -2892,7 +2882,7 @@ def get_handles():
2892
2882
else :
2893
2883
# LINES, LABELS
2894
2884
handles , labels = args
2895
- loc = popd ( kwargs , 'loc' , 1 )
2885
+ loc = kwargs . pop ( 'loc' , 1 )
2896
2886
2897
2887
elif len (args )== 3 :
2898
2888
# LINES, LABELS, LOC
@@ -3776,7 +3766,6 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
3776
3766
'8' : (8 ,0 ), # octagon
3777
3767
}
3778
3768
3779
- kwargs = kwargs .copy ()
3780
3769
self ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
3781
3770
3782
3771
x , y , s , c = delete_masked_points (x , y , s , c )
@@ -4068,15 +4057,14 @@ def quiver_classic(self, U, V, *args, **kwargs ):
4068
4057
V = V * (S / Nmax )
4069
4058
N = N * Nmax
4070
4059
4071
- kwargs = kwargs .copy ()
4072
- alpha = popd (kwargs ,'alpha' , 1.0 )
4073
- width = popd (kwargs ,'width' , .5 )
4074
- norm = popd (kwargs ,'norm' , None )
4075
- cmap = popd (kwargs ,'cmap' , None )
4076
- vmin = popd (kwargs ,'vmin' , None )
4077
- vmax = popd (kwargs ,'vmax' , None )
4078
- color = popd (kwargs ,'color' , None )
4079
- shading = popd (kwargs ,'shading' , 'faceted' )
4060
+ alpha = kwargs .pop ('alpha' , 1.0 )
4061
+ width = kwargs .pop ('width' , .5 )
4062
+ norm = kwargs .pop ('norm' , None )
4063
+ cmap = kwargs .pop ('cmap' , None )
4064
+ vmin = kwargs .pop ('vmin' , None )
4065
+ vmax = kwargs .pop ('vmax' , None )
4066
+ color = kwargs .pop ('color' , None )
4067
+ shading = kwargs .pop ('shading' , 'faceted' )
4080
4068
4081
4069
if len (kwargs ):
4082
4070
raise TypeError , "quiver() got an unexpected keyword argument '%s'" % kwargs .keys ()[0 ]
@@ -4151,8 +4139,6 @@ def fill(self, *args, **kwargs):
4151
4139
kwargs control the Polygon properties:
4152
4140
%(Polygon)s
4153
4141
"""
4154
- kwargs = kwargs .copy ()
4155
-
4156
4142
if not self ._hold : self .cla ()
4157
4143
4158
4144
patches = []
@@ -4974,7 +4960,7 @@ def spy(self, Z, precision=None, marker=None, markersize=None,
4974
4960
self .set_aspect (aspect )
4975
4961
ret = lines
4976
4962
self .title .set_y (1.05 )
4977
- self .xaxis .tick_top ( )
4963
+ self .xaxis .set_label_position ( 'top' )
4978
4964
self .xaxis .set_major_locator (MaxNLocator (integer = True ))
4979
4965
self .yaxis .set_major_locator (MaxNLocator (integer = True ))
4980
4966
return ret
@@ -5010,7 +4996,7 @@ def matshow(self, Z, **kwargs):
5010
4996
kw .update (kwargs )
5011
4997
im = self .imshow (Z , ** kw )
5012
4998
self .title .set_y (1.05 )
5013
- self .xaxis .tick_top ( )
4999
+ self .xaxis .set_label_position ( 'top' )
5014
5000
self .xaxis .set_major_locator (MaxNLocator (integer = True ))
5015
5001
self .yaxis .set_major_locator (MaxNLocator (integer = True ))
5016
5002
return im
0 commit comments