@@ -1279,24 +1279,31 @@ def axis(self, *v, **kwargs):
12791279 ymin , ymax = self .get_ylim ()
12801280 return xmin , xmax , ymin , ymax
12811281
1282- try : v [0 ]
1282+ emit = kwargs .get ('emit' , True )
1283+ try :
1284+ v [0 ]
12831285 except IndexError :
1284- emit = kwargs .get ('emit' , True )
12851286 xmin = kwargs .get ('xmin' , None )
12861287 xmax = kwargs .get ('xmax' , None )
1288+ auto = False # turn off autoscaling, unless...
1289+ if xmin is None and xmax is None :
1290+ auto = None # leave autoscaling state alone
1291+ xmin , xmax = self .set_xlim (xmin , xmax , emit = emit , auto = auto )
12871292
1288- xmin , xmax = self .set_xlim (xmin , xmax , emit )
12891293 ymin = kwargs .get ('ymin' , None )
12901294 ymax = kwargs .get ('ymax' , None )
1291- ymin , ymax = self .set_ylim (ymin , ymax , emit )
1295+ auto = False # turn off autoscaling, unless...
1296+ if ymin is None and ymax is None :
1297+ auto = None # leave autoscaling state alone
1298+ ymin , ymax = self .set_ylim (ymin , ymax , emit = emit , auto = auto )
12921299 return xmin , xmax , ymin , ymax
12931300
12941301 v = v [0 ]
12951302 if len (v ) != 4 :
12961303 raise ValueError ('v must contain [xmin xmax ymin ymax]' )
12971304
1298- self .set_xlim ([v [0 ], v [1 ]])
1299- self .set_ylim ([v [2 ], v [3 ]])
1305+ self .set_xlim ([v [0 ], v [1 ]], emit = emit , auto = False )
1306+ self .set_ylim ([v [2 ], v [3 ]], emit = emit , auto = False )
13001307
13011308 return v
13021309
0 commit comments