@@ -2298,11 +2298,11 @@ def set_xbound(self, lower=None, upper=None):
2298
2298
2299
2299
def get_xlim (self ):
2300
2300
"""
2301
- Get the x-axis range [*xmin *, *xmax *]
2301
+ Get the x-axis range [*left *, *right *]
2302
2302
"""
2303
2303
return tuple (self .viewLim .intervalx )
2304
2304
2305
- def set_xlim (self , xmin = None , xmax = None , emit = True , auto = False ):
2305
+ def set_xlim (self , left = None , right = None , emit = True , auto = False , ** kw ):
2306
2306
"""
2307
2307
call signature::
2308
2308
@@ -2314,23 +2314,23 @@ def set_xlim(self, xmin=None, xmax=None, emit=True, auto=False):
2314
2314
2315
2315
set_xlim((left, right))
2316
2316
set_xlim(left, right)
2317
- set_xlim(xmin =1) # right unchanged
2318
- set_xlim(xmax =1) # left unchanged
2317
+ set_xlim(left =1) # right unchanged
2318
+ set_xlim(right =1) # left unchanged
2319
2319
2320
2320
Keyword arguments:
2321
2321
2322
- *xmin *: scalar
2323
- the left xlim
2324
- *xmax *: scalar
2325
- the right xlim
2322
+ *left *: scalar
2323
+ the left xlim; *xmin*, the previous name, may still be used
2324
+ *right *: scalar
2325
+ the right xlim; *xmax*, the previous name, may still be used
2326
2326
*emit*: [ True | False ]
2327
2327
notify observers of lim change
2328
2328
*auto*: [ True | False | None ]
2329
2329
turn *x* autoscaling on (True), off (False; default),
2330
2330
or leave unchanged (None)
2331
2331
2332
- Note: the kwarg terminology may be confusing. The first value,
2333
- *xmin*, is the left, and the second, *xmax*, is the right .
2332
+ Note: the *left* (formerly *xmin*) value may be greater than
2333
+ the *right* (formerly *xmax*) .
2334
2334
For example, suppose *x* is years before present.
2335
2335
Then one might use::
2336
2336
@@ -2343,26 +2343,34 @@ def set_xlim(self, xmin=None, xmax=None, emit=True, auto=False):
2343
2343
2344
2344
ACCEPTS: len(2) sequence of floats
2345
2345
"""
2346
- if xmax is None and iterable (xmin ):
2347
- xmin ,xmax = xmin
2348
-
2349
-
2350
- self ._process_unit_info (xdata = (xmin , xmax ))
2351
- if xmin is not None :
2352
- xmin = self .convert_xunits (xmin )
2353
- if xmax is not None :
2354
- xmax = self .convert_xunits (xmax )
2355
-
2356
- old_xmin ,old_xmax = self .get_xlim ()
2357
- if xmin is None : xmin = old_xmin
2358
- if xmax is None : xmax = old_xmax
2359
-
2360
- if xmin == xmax :
2361
- warnings .warn ('Attempting to set identical xmin==xmax results in singular transformations; automatically expanding. xmin=%s, xmax=%s' % (xmin , xmax ))
2362
- xmin , xmax = mtransforms .nonsingular (xmin , xmax , increasing = False )
2363
- xmin , xmax = self .xaxis .limit_range_for_scale (xmin , xmax )
2364
-
2365
- self .viewLim .intervalx = (xmin , xmax )
2346
+ if 'xmin' in kw :
2347
+ left = kw .pop ('xmin' )
2348
+ if 'xmax' in kw :
2349
+ right = kw .pop ('xmax' )
2350
+ if kw :
2351
+ raise ValueError ("unrecognized kwargs: %s" % kw .keys ())
2352
+
2353
+ if right is None and iterable (left ):
2354
+ left ,right = left
2355
+
2356
+ self ._process_unit_info (xdata = (left , right ))
2357
+ if left is not None :
2358
+ left = self .convert_xunits (left )
2359
+ if right is not None :
2360
+ right = self .convert_xunits (right )
2361
+
2362
+ old_left , old_right = self .get_xlim ()
2363
+ if left is None : left = old_left
2364
+ if right is None : right = old_right
2365
+
2366
+ if left == right :
2367
+ warnings .warn (('Attempting to set identical left==right results\n '
2368
+ + 'in singular transformations; automatically expanding.\n '
2369
+ + 'left=%s, right=%s' ) % (left , right ))
2370
+ left , right = mtransforms .nonsingular (left , right , increasing = False )
2371
+ left , right = self .xaxis .limit_range_for_scale (left , right )
2372
+
2373
+ self .viewLim .intervalx = (left , right )
2366
2374
if auto is not None :
2367
2375
self ._autoscaleXon = bool (auto )
2368
2376
@@ -2377,7 +2385,7 @@ def set_xlim(self, xmin=None, xmax=None, emit=True, auto=False):
2377
2385
other .figure .canvas is not None ):
2378
2386
other .figure .canvas .draw_idle ()
2379
2387
2380
- return xmin , xmax
2388
+ return left , right
2381
2389
2382
2390
def get_xscale (self ):
2383
2391
'return the xaxis scale string: %s' % (
@@ -2492,11 +2500,11 @@ def set_ybound(self, lower=None, upper=None):
2492
2500
2493
2501
def get_ylim (self ):
2494
2502
"""
2495
- Get the y-axis range [*ymin *, *ymax *]
2503
+ Get the y-axis range [*bottom *, *top *]
2496
2504
"""
2497
2505
return tuple (self .viewLim .intervaly )
2498
2506
2499
- def set_ylim (self , ymin = None , ymax = None , emit = True , auto = False ):
2507
+ def set_ylim (self , bottom = None , top = None , emit = True , auto = False , ** kw ):
2500
2508
"""
2501
2509
call signature::
2502
2510
@@ -2508,23 +2516,23 @@ def set_ylim(self, ymin=None, ymax=None, emit=True, auto=False):
2508
2516
2509
2517
set_ylim((bottom, top))
2510
2518
set_ylim(bottom, top)
2511
- set_ylim(ymin =1) # top unchanged
2512
- set_ylim(ymax =1) # bottom unchanged
2519
+ set_ylim(bottom =1) # top unchanged
2520
+ set_ylim(top =1) # bottom unchanged
2513
2521
2514
2522
Keyword arguments:
2515
2523
2516
- *ymin *: scalar
2517
- the bottom ylim
2518
- *ymax *: scalar
2519
- the top ylim
2524
+ *bottom *: scalar
2525
+ the bottom ylim; the previous name, *ymin*, may still be used
2526
+ *top *: scalar
2527
+ the top ylim; the previous name, *ymax*, may still be used
2520
2528
*emit*: [ True | False ]
2521
2529
notify observers of lim change
2522
2530
*auto*: [ True | False | None ]
2523
2531
turn *y* autoscaling on (True), off (False; default),
2524
2532
or leave unchanged (None)
2525
2533
2526
- Note: the kwarg terminology may be confusing. The first value,
2527
- *ymin*, is the bottom, and the second, *ymax*, is the top .
2534
+ Note: the *bottom* (formerly *ymin*) value may be greater than
2535
+ the *top* (formerly *ymax*) .
2528
2536
For example, suppose *y* is depth in the ocean.
2529
2537
Then one might use::
2530
2538
@@ -2537,26 +2545,35 @@ def set_ylim(self, ymin=None, ymax=None, emit=True, auto=False):
2537
2545
2538
2546
ACCEPTS: len(2) sequence of floats
2539
2547
"""
2540
- if ymax is None and iterable (ymin ):
2541
- ymin ,ymax = ymin
2548
+ if 'ymin' in kw :
2549
+ bottom = kw .pop ('ymin' )
2550
+ if 'ymax' in kw :
2551
+ top = kw .pop ('ymax' )
2552
+ if kw :
2553
+ raise ValueError ("unrecognized kwargs: %s" % kw .keys ())
2554
+
2555
+ if top is None and iterable (bottom ):
2556
+ bottom ,top = bottom
2542
2557
2543
- if ymin is not None :
2544
- ymin = self .convert_yunits (ymin )
2545
- if ymax is not None :
2546
- ymax = self .convert_yunits (ymax )
2558
+ if bottom is not None :
2559
+ bottom = self .convert_yunits (bottom )
2560
+ if top is not None :
2561
+ top = self .convert_yunits (top )
2547
2562
2548
- old_ymin , old_ymax = self .get_ylim ()
2563
+ old_bottom , old_top = self .get_ylim ()
2549
2564
2550
- if ymin is None : ymin = old_ymin
2551
- if ymax is None : ymax = old_ymax
2565
+ if bottom is None : bottom = old_bottom
2566
+ if top is None : top = old_top
2552
2567
2553
- if ymin == ymax :
2554
- warnings .warn ('Attempting to set identical ymin==ymax results in singular transformations; automatically expanding. ymin=%s, ymax=%s' % (ymin , ymax ))
2568
+ if bottom == top :
2569
+ warnings .warn (('Attempting to set identical bottom==top results\n '
2570
+ + 'in singular transformations; automatically expanding.\n '
2571
+ + 'bottom=%s, top=%s' ) % (bottom , top ))
2555
2572
2556
- ymin , ymax = mtransforms .nonsingular (ymin , ymax , increasing = False )
2557
- ymin , ymax = self .yaxis .limit_range_for_scale (ymin , ymax )
2573
+ bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
2574
+ bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
2558
2575
2559
- self .viewLim .intervaly = (ymin , ymax )
2576
+ self .viewLim .intervaly = (bottom , top )
2560
2577
if auto is not None :
2561
2578
self ._autoscaleYon = bool (auto )
2562
2579
@@ -2571,7 +2588,7 @@ def set_ylim(self, ymin=None, ymax=None, emit=True, auto=False):
2571
2588
other .figure .canvas is not None ):
2572
2589
other .figure .canvas .draw_idle ()
2573
2590
2574
- return ymin , ymax
2591
+ return bottom , top
2575
2592
2576
2593
def get_yscale (self ):
2577
2594
'return the xaxis scale string: %s' % (
0 commit comments