@@ -1273,24 +1273,31 @@ def axis(self, *v, **kwargs):
1273
1273
ymin , ymax = self .get_ylim ()
1274
1274
return xmin , xmax , ymin , ymax
1275
1275
1276
- try : v [0 ]
1276
+ emit = kwargs .get ('emit' , True )
1277
+ try :
1278
+ v [0 ]
1277
1279
except IndexError :
1278
- emit = kwargs .get ('emit' , True )
1279
1280
xmin = kwargs .get ('xmin' , None )
1280
1281
xmax = kwargs .get ('xmax' , None )
1282
+ auto = False # turn off autoscaling, unless...
1283
+ if xmin is None and xmax is None :
1284
+ auto = None # leave autoscaling state alone
1285
+ xmin , xmax = self .set_xlim (xmin , xmax , emit = emit , auto = auto )
1281
1286
1282
- xmin , xmax = self .set_xlim (xmin , xmax , emit )
1283
1287
ymin = kwargs .get ('ymin' , None )
1284
1288
ymax = kwargs .get ('ymax' , None )
1285
- ymin , ymax = self .set_ylim (ymin , ymax , emit )
1289
+ auto = False # turn off autoscaling, unless...
1290
+ if ymin is None and ymax is None :
1291
+ auto = None # leave autoscaling state alone
1292
+ ymin , ymax = self .set_ylim (ymin , ymax , emit = emit , auto = auto )
1286
1293
return xmin , xmax , ymin , ymax
1287
1294
1288
1295
v = v [0 ]
1289
1296
if len (v ) != 4 :
1290
1297
raise ValueError ('v must contain [xmin xmax ymin ymax]' )
1291
1298
1292
- self .set_xlim ([v [0 ], v [1 ]])
1293
- self .set_ylim ([v [2 ], v [3 ]])
1299
+ self .set_xlim ([v [0 ], v [1 ]], emit = emit , auto = False )
1300
+ self .set_ylim ([v [2 ], v [3 ]], emit = emit , auto = False )
1294
1301
1295
1302
return v
1296
1303
0 commit comments