@@ -1312,8 +1312,7 @@ def add_line(self, line):
13121312 self ._set_artist_props (line )
13131313 line .set_clip_path (self .patch )
13141314
1315- if line .get_transform () == self .transData :
1316- self ._update_line_limits (line )
1315+ self ._update_line_limits (line )
13171316 if not line .get_label ():
13181317 line .set_label ('_line%d' % len (self .lines ))
13191318 self .lines .append (line )
@@ -1322,7 +1321,9 @@ def add_line(self, line):
13221321 def _update_line_limits (self , line ):
13231322 p = line .get_path ()
13241323 if p .vertices .size > 0 :
1325- self .dataLim .update_from_path (p , self .ignore_existing_data_limits )
1324+ self .dataLim .update_from_path (p , self .ignore_existing_data_limits ,
1325+ updatex = line .x_isdata ,
1326+ updatey = line .y_isdata )
13261327 self .ignore_existing_data_limits = False
13271328
13281329 def add_patch (self , p ):
@@ -1356,7 +1357,8 @@ def _update_patch_limits(self, patch):
13561357 transform = (patch .get_data_transform () +
13571358 self .transData .inverted ())
13581359 xys = transform .transform (xys )
1359- self .update_datalim (xys )
1360+ self .update_datalim (xys , updatex = patch .x_isdata ,
1361+ updatey = patch .y_isdata )
13601362
13611363
13621364 def add_table (self , tab ):
@@ -1381,7 +1383,7 @@ def relim(self):
13811383 for p in self .patches :
13821384 self ._update_patch_limits (p )
13831385
1384- def update_datalim (self , xys ):
1386+ def update_datalim (self , xys , updatex = True , updatey = True ):
13851387 'Update the data lim bbox with seq of xy tups or equiv. 2-D array'
13861388 # if no data is set currently, the bbox will ignore its
13871389 # limits and set the bound to be the bounds of the xydata.
@@ -1391,7 +1393,8 @@ def update_datalim(self, xys):
13911393 if iterable (xys ) and not len (xys ): return
13921394 if not ma .isMaskedArray (xys ):
13931395 xys = np .asarray (xys )
1394- self .dataLim .update_from_data_xy (xys , self .ignore_existing_data_limits )
1396+ self .dataLim .update_from_data_xy (xys , self .ignore_existing_data_limits ,
1397+ updatex = updatex , updatey = updatey )
13951398 self .ignore_existing_data_limits = False
13961399
13971400 def update_datalim_numerix (self , x , y ):
@@ -2776,11 +2779,9 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
27762779 trans = mtransforms .blended_transform_factory (
27772780 self .transAxes , self .transData )
27782781 l = mlines .Line2D ([xmin ,xmax ], [y ,y ], transform = trans , ** kwargs )
2782+ l .x_isdata = False
27792783 self .add_line (l )
2780- self .dataLim .y0 = min (self .dataLim .y0 , yy )
2781- self .dataLim .y1 = max (self .dataLim .y1 , yy )
27822784 self .autoscale_view (scalex = False , scaley = scaley )
2783-
27842785 return l
27852786
27862787 axhline .__doc__ = cbook .dedent (axhline .__doc__ ) % martist .kwdocd
@@ -2836,11 +2837,9 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
28362837 trans = mtransforms .blended_transform_factory (
28372838 self .transData , self .transAxes )
28382839 l = mlines .Line2D ([x ,x ], [ymin ,ymax ] , transform = trans , ** kwargs )
2840+ l .y_isdata = False
28392841 self .add_line (l )
2840- self .dataLim .x0 = min (self .dataLim .x0 , xx )
2841- self .dataLim .x1 = max (self .dataLim .x1 , xx )
28422842 self .autoscale_view (scalex = scalex , scaley = False )
2843-
28442843 return l
28452844
28462845 axvline .__doc__ = cbook .dedent (axvline .__doc__ ) % martist .kwdocd
@@ -2858,7 +2857,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
28582857
28592858 Draw a horizontal span (rectangle) from *ymin* to *ymax*.
28602859 With the default values of *xmin* = 0 and *xmax* = 1, this
2861- always span the xrange, regardless of the xlim settings, even
2860+ always spans the xrange, regardless of the xlim settings, even
28622861 if you change them, eg. with the :meth:`set_xlim` command.
28632862 That is, the horizontal extent is in axes coords: 0=left,
28642863 0.5=middle, 1.0=right but the *y* location is in data
@@ -2896,6 +2895,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
28962895 verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
28972896 p = mpatches .Polygon (verts , ** kwargs )
28982897 p .set_transform (trans )
2898+ p .x_isdata = False
28992899 self .add_patch (p )
29002900 return p
29012901 axhspan .__doc__ = cbook .dedent (axhspan .__doc__ ) % martist .kwdocd
@@ -2913,7 +2913,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
29132913
29142914 Draw a vertical span (rectangle) from *xmin* to *xmax*. With
29152915 the default values of *ymin* = 0 and *ymax* = 1, this always
2916- span the yrange, regardless of the ylim settings, even if you
2916+ spans the yrange, regardless of the ylim settings, even if you
29172917 change them, eg. with the :meth:`set_ylim` command. That is,
29182918 the vertical extent is in axes coords: 0=bottom, 0.5=middle,
29192919 1.0=top but the *y* location is in data coordinates.
@@ -2950,6 +2950,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
29502950 verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
29512951 p = mpatches .Polygon (verts , ** kwargs )
29522952 p .set_transform (trans )
2953+ p .y_isdata = False
29532954 self .add_patch (p )
29542955 return p
29552956 axvspan .__doc__ = cbook .dedent (axvspan .__doc__ ) % martist .kwdocd
0 commit comments