@@ -766,6 +766,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
766766 same as levels for line contours; half-way between
767767 levels for filled contours. See :meth:`_process_colors`.
768768 """
769+
769770 def __init__ (self , ax , * args , ** kwargs ):
770771 """
771772 Draw contour lines or filled regions, depending on
@@ -804,7 +805,7 @@ def __init__(self, ax, *args, **kwargs):
804805 level0segs = [polygon0] and level0kinds = [polygon0kinds].
805806
806807 Keyword arguments are as described in
807- :class:`~ matplotlib.contour.QuadContourSet` object .
808+ :attr:` matplotlib.contour.QuadContourSet.contour_doc` .
808809
809810 **Examples:**
810811
@@ -937,8 +938,7 @@ def __init__(self, ax, *args, **kwargs):
937938 edgecolors = 'none' ,
938939 alpha = self .alpha ,
939940 transform = self .get_transform (),
940- zorder = zorder ,
941- margins = False )
941+ zorder = zorder )
942942 self .ax .add_collection (col , autolim = False )
943943 self .collections .append (col )
944944 else :
@@ -959,11 +959,18 @@ def __init__(self, ax, *args, **kwargs):
959959 linestyles = [lstyle ],
960960 alpha = self .alpha ,
961961 transform = self .get_transform (),
962- zorder = zorder ,
963- margins = False )
962+ zorder = zorder )
964963 col .set_label ('_nolegend_' )
965964 self .ax .add_collection (col , autolim = False )
966965 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+
967974 self .changed () # set the colors
968975
969976 def get_transform (self ):
@@ -1069,21 +1076,13 @@ def _process_args(self, *args, **kwargs):
10691076 raise ValueError ('allkinds has different length to allsegs' )
10701077
10711078 # 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 ]
10871086
10881087 def _get_allsegs_and_allkinds (self ):
10891088 """
@@ -1423,16 +1422,6 @@ class QuadContourSet(ContourSet):
14231422 Same as levels for line contours; half-way between
14241423 levels for filled contours. See :meth:`_process_colors` method.
14251424 """
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 )
14361425
14371426 def _process_args (self , * args , ** kwargs ):
14381427 """
@@ -1448,6 +1437,7 @@ def _process_args(self, *args, **kwargs):
14481437 contour_generator = args [0 ].Cntr
14491438 else :
14501439 contour_generator = args [0 ]._contour_generator
1440+ self ._stickies = args [0 ]._stickies
14511441 else :
14521442 self ._corner_mask = kwargs .get ('corner_mask' , None )
14531443 if self ._corner_mask is None :
@@ -1480,12 +1470,7 @@ def _process_args(self, *args, **kwargs):
14801470 x = transformed_pts [..., 0 ]
14811471 y = transformed_pts [..., 1 ]
14821472
1483- x0 = ma .minimum (x )
1484- x1 = ma .maximum (x )
1485- y0 = ma .minimum (y )
1486- y1 = ma .maximum (y )
1487- self .ax .update_datalim ([(x0 , y0 ), (x1 , y1 )])
1488- self .ax .autoscale_view (tight = True )
1473+ self ._stickies = [(ma .min (x ), ma .min (y )), (ma .max (x ), ma .max (y ))]
14891474
14901475 if self ._corner_mask == 'legacy' :
14911476 self .Cntr = contour_generator
0 commit comments