@@ -800,32 +800,32 @@ def __init__(self, ax, *args, **kwargs):
800
800
:attr:`matplotlib.contour.QuadContourSet.contour_doc`.
801
801
"""
802
802
self .ax = ax
803
- self .levels = kwargs .get ('levels' , None )
804
- self .filled = kwargs .get ('filled' , False )
805
- self .linewidths = kwargs .get ('linewidths' , None )
806
- self .linestyles = kwargs .get ('linestyles' , None )
807
-
808
- self .hatches = kwargs .get ('hatches' , [None ])
809
-
810
- self .alpha = kwargs .get ('alpha' , None )
811
- self .origin = kwargs .get ('origin' , None )
812
- self .extent = kwargs .get ('extent' , None )
813
- cmap = kwargs .get ('cmap' , None )
814
- self .colors = kwargs .get ('colors' , None )
815
- norm = kwargs .get ('norm' , None )
816
- vmin = kwargs .get ('vmin' , None )
817
- vmax = kwargs .get ('vmax' , None )
818
- self .extend = kwargs .get ('extend' , 'neither' )
819
- self .antialiased = kwargs .get ('antialiased' , None )
803
+ self .levels = kwargs .pop ('levels' , None )
804
+ self .filled = kwargs .pop ('filled' , False )
805
+ self .linewidths = kwargs .pop ('linewidths' , None )
806
+ self .linestyles = kwargs .pop ('linestyles' , None )
807
+
808
+ self .hatches = kwargs .pop ('hatches' , [None ])
809
+
810
+ self .alpha = kwargs .pop ('alpha' , None )
811
+ self .origin = kwargs .pop ('origin' , None )
812
+ self .extent = kwargs .pop ('extent' , None )
813
+ cmap = kwargs .pop ('cmap' , None )
814
+ self .colors = kwargs .pop ('colors' , None )
815
+ norm = kwargs .pop ('norm' , None )
816
+ vmin = kwargs .pop ('vmin' , None )
817
+ vmax = kwargs .pop ('vmax' , None )
818
+ self .extend = kwargs .pop ('extend' , 'neither' )
819
+ self .antialiased = kwargs .pop ('antialiased' , None )
820
820
if self .antialiased is None and self .filled :
821
821
self .antialiased = False # eliminate artifacts; we are not
822
822
# stroking the boundaries.
823
823
# The default for line contours will be taken from
824
824
# the LineCollection default, which uses the
825
825
# rcParams['lines.antialiased']
826
826
827
- self .nchunk = kwargs .get ('nchunk' , 0 )
828
- self .locator = kwargs .get ('locator' , None )
827
+ self .nchunk = kwargs .pop ('nchunk' , 0 )
828
+ self .locator = kwargs .pop ('locator' , None )
829
829
if (isinstance (norm , colors .LogNorm )
830
830
or isinstance (self .locator , ticker .LogLocator )):
831
831
self .logscale = True
@@ -848,9 +848,9 @@ def __init__(self, ax, *args, **kwargs):
848
848
if self .origin == 'image' :
849
849
self .origin = mpl .rcParams ['image.origin' ]
850
850
851
- self ._transform = kwargs .get ('transform' , None )
851
+ self ._transform = kwargs .pop ('transform' , None )
852
852
853
- self ._process_args (* args , ** kwargs )
853
+ kwargs = self ._process_args (* args , ** kwargs )
854
854
self ._process_levels ()
855
855
856
856
if self .colors is not None :
@@ -915,11 +915,12 @@ def __init__(self, ax, *args, **kwargs):
915
915
if self .allkinds is None :
916
916
self .allkinds = [None ] * len (self .allsegs )
917
917
918
+ # Default zorder taken from Collection
919
+ zorder = kwargs .pop ('zorder' , 1 )
918
920
for level , level_upper , segs , kinds in \
919
921
zip (lowers , uppers , self .allsegs , self .allkinds ):
920
922
paths = self ._make_paths (segs , kinds )
921
- # Default zorder taken from Collection
922
- zorder = kwargs .get ('zorder' , 1 )
923
+
923
924
col = mcoll .PathCollection (
924
925
paths ,
925
926
antialiaseds = (self .antialiased ,),
@@ -936,10 +937,10 @@ def __init__(self, ax, *args, **kwargs):
936
937
aa = self .antialiased
937
938
if aa is not None :
938
939
aa = (self .antialiased ,)
940
+ # Default zorder taken from LineCollection
941
+ zorder = kwargs .pop ('zorder' , 2 )
939
942
for level , width , lstyle , segs in \
940
943
zip (self .levels , tlinewidths , tlinestyles , self .allsegs ):
941
- # Default zorder taken from LineCollection
942
- zorder = kwargs .get ('zorder' , 2 )
943
944
col = mcoll .LineCollection (
944
945
segs ,
945
946
antialiaseds = aa ,
@@ -960,6 +961,11 @@ def __init__(self, ax, *args, **kwargs):
960
961
961
962
self .changed () # set the colors
962
963
964
+ if kwargs :
965
+ s = ", " .join (map (repr , kwargs ))
966
+ warnings .warn ('The following kwargs were not used by contour: ' +
967
+ s )
968
+
963
969
def get_transform (self ):
964
970
"""
965
971
Return the :class:`~matplotlib.transforms.Transform`
@@ -1068,6 +1074,8 @@ def _process_args(self, *args, **kwargs):
1068
1074
self ._mins = points .min (axis = 0 )
1069
1075
self ._maxs = points .max (axis = 0 )
1070
1076
1077
+ return kwargs
1078
+
1071
1079
def _get_allsegs_and_allkinds (self ):
1072
1080
"""
1073
1081
Override in derived classes to create and return allsegs and allkinds.
@@ -1431,7 +1439,7 @@ def _process_args(self, *args, **kwargs):
1431
1439
self ._mins = args [0 ]._mins
1432
1440
self ._maxs = args [0 ]._maxs
1433
1441
else :
1434
- self ._corner_mask = kwargs .get ('corner_mask' , None )
1442
+ self ._corner_mask = kwargs .pop ('corner_mask' , None )
1435
1443
if self ._corner_mask is None :
1436
1444
self ._corner_mask = mpl .rcParams ['contour.corner_mask' ]
1437
1445
@@ -1470,6 +1478,8 @@ def _process_args(self, *args, **kwargs):
1470
1478
else :
1471
1479
self ._contour_generator = contour_generator
1472
1480
1481
+ return kwargs
1482
+
1473
1483
def _get_allsegs_and_allkinds (self ):
1474
1484
"""
1475
1485
Create and return allsegs and allkinds by calling underlying C code.
@@ -1539,7 +1549,7 @@ def _check_xyz(self, args, kwargs):
1539
1549
Exception class (here and elsewhere).
1540
1550
"""
1541
1551
x , y = args [:2 ]
1542
- self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1552
+ kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1543
1553
x = self .ax .convert_xunits (x )
1544
1554
y = self .ax .convert_yunits (y )
1545
1555
0 commit comments