@@ -766,6 +766,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
766
766
same as levels for line contours; half-way between
767
767
levels for filled contours. See :meth:`_process_colors`.
768
768
"""
769
+
769
770
def __init__ (self , ax , * args , ** kwargs ):
770
771
"""
771
772
Draw contour lines or filled regions, depending on
@@ -804,7 +805,7 @@ def __init__(self, ax, *args, **kwargs):
804
805
level0segs = [polygon0] and level0kinds = [polygon0kinds].
805
806
806
807
Keyword arguments are as described in
807
- :class:`~ matplotlib.contour.QuadContourSet` object .
808
+ :attr:` matplotlib.contour.QuadContourSet.contour_doc` .
808
809
809
810
**Examples:**
810
811
@@ -937,8 +938,7 @@ def __init__(self, ax, *args, **kwargs):
937
938
edgecolors = 'none' ,
938
939
alpha = self .alpha ,
939
940
transform = self .get_transform (),
940
- zorder = zorder ,
941
- margins = False )
941
+ zorder = zorder )
942
942
self .ax .add_collection (col , autolim = False )
943
943
self .collections .append (col )
944
944
else :
@@ -959,11 +959,18 @@ def __init__(self, ax, *args, **kwargs):
959
959
linestyles = [lstyle ],
960
960
alpha = self .alpha ,
961
961
transform = self .get_transform (),
962
- zorder = zorder ,
963
- margins = False )
962
+ zorder = zorder )
964
963
col .set_label ('_nolegend_' )
965
964
self .ax .add_collection (col , autolim = False )
966
965
self .collections .append (col )
966
+
967
+ mins , maxs = self ._stickies
968
+ for col in self .collections :
969
+ col .stickies .x [:] = [mins [0 ], maxs [0 ]]
970
+ col .stickies .y [:] = [mins [1 ], maxs [1 ]]
971
+ self .ax .update_datalim ([mins , maxs ])
972
+ self .ax .autoscale_view (tight = True )
973
+
967
974
self .changed () # set the colors
968
975
969
976
def get_transform (self ):
@@ -1069,21 +1076,13 @@ def _process_args(self, *args, **kwargs):
1069
1076
raise ValueError ('allkinds has different length to allsegs' )
1070
1077
1071
1078
# Determine x,y bounds and update axes data limits.
1072
- havelimits = False
1073
- for segs in self .allsegs :
1074
- for seg in segs :
1075
- seg = np .asarray (seg )
1076
- if havelimits :
1077
- min = np .minimum (min , seg .min (axis = 0 ))
1078
- max = np .maximum (max , seg .max (axis = 0 ))
1079
- else :
1080
- min = seg .min (axis = 0 )
1081
- max = seg .max (axis = 0 )
1082
- havelimits = True
1083
-
1084
- if havelimits :
1085
- self .ax .update_datalim ([min , max ])
1086
- self .ax .autoscale_view (tight = True )
1079
+ mins = np .min (
1080
+ [np .min (seg , axis = 0 ) for segs in self .allsegs for seg in segs ],
1081
+ axis = 0 )
1082
+ maxs = np .max (
1083
+ [np .max (seg , axis = 0 ) for segs in self .allsegs for seg in segs ],
1084
+ axis = 0 )
1085
+ self ._stickies = [mins , maxs ]
1087
1086
1088
1087
def _get_allsegs_and_allkinds (self ):
1089
1088
"""
@@ -1423,16 +1422,6 @@ class QuadContourSet(ContourSet):
1423
1422
Same as levels for line contours; half-way between
1424
1423
levels for filled contours. See :meth:`_process_colors` method.
1425
1424
"""
1426
- def __init__ (self , ax , * args , ** kwargs ):
1427
- """
1428
- Calculate and draw contour lines or filled regions, depending
1429
- on whether keyword arg 'filled' is False (default) or True.
1430
-
1431
- The first argument of the initializer must be an axes
1432
- object. The remaining arguments and keyword arguments
1433
- are described in QuadContourSet.contour_doc.
1434
- """
1435
- ContourSet .__init__ (self , ax , * args , ** kwargs )
1436
1425
1437
1426
def _process_args (self , * args , ** kwargs ):
1438
1427
"""
@@ -1448,6 +1437,7 @@ def _process_args(self, *args, **kwargs):
1448
1437
contour_generator = args [0 ].Cntr
1449
1438
else :
1450
1439
contour_generator = args [0 ]._contour_generator
1440
+ self ._stickies = args [0 ]._stickies
1451
1441
else :
1452
1442
self ._corner_mask = kwargs .get ('corner_mask' , None )
1453
1443
if self ._corner_mask is None :
@@ -1484,8 +1474,7 @@ def _process_args(self, *args, **kwargs):
1484
1474
x1 = ma .maximum (x )
1485
1475
y0 = ma .minimum (y )
1486
1476
y1 = ma .maximum (y )
1487
- self .ax .update_datalim ([(x0 , y0 ), (x1 , y1 )])
1488
- self .ax .autoscale_view (tight = True )
1477
+ self ._stickies = [(x0 , y0 ), (x1 , y1 )]
1489
1478
1490
1479
if self ._corner_mask == 'legacy' :
1491
1480
self .Cntr = contour_generator
0 commit comments