@@ -1279,24 +1279,31 @@ def axis(self, *v, **kwargs):
1279
1279
ymin , ymax = self .get_ylim ()
1280
1280
return xmin , xmax , ymin , ymax
1281
1281
1282
- try : v [0 ]
1282
+ emit = kwargs .get ('emit' , True )
1283
+ try :
1284
+ v [0 ]
1283
1285
except IndexError :
1284
- emit = kwargs .get ('emit' , True )
1285
1286
xmin = kwargs .get ('xmin' , None )
1286
1287
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 )
1287
1292
1288
- xmin , xmax = self .set_xlim (xmin , xmax , emit )
1289
1293
ymin = kwargs .get ('ymin' , None )
1290
1294
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 )
1292
1299
return xmin , xmax , ymin , ymax
1293
1300
1294
1301
v = v [0 ]
1295
1302
if len (v ) != 4 :
1296
1303
raise ValueError ('v must contain [xmin xmax ymin ymax]' )
1297
1304
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 )
1300
1307
1301
1308
return v
1302
1309
0 commit comments