@@ -487,7 +487,6 @@ def __init__(self, fig, rect,
487
487
if self ._position .width < 0 or self ._position .height < 0 :
488
488
raise ValueError ('Width and height specified must be non-negative' )
489
489
self ._originalPosition = self ._position .frozen ()
490
- # self.set_axes(self)
491
490
self .axes = self
492
491
self .set_aspect ('auto' )
493
492
self ._adjustable = 'box'
@@ -498,15 +497,11 @@ def __init__(self, fig, rect,
498
497
self ._shared_x_axes .join (self , sharex )
499
498
if sharex ._adjustable == 'box' :
500
499
sharex ._adjustable = 'datalim'
501
- # warnings.warn(
502
- # 'shared axes: "adjustable" is being changed to "datalim"')
503
500
self ._adjustable = 'datalim'
504
501
if sharey is not None :
505
502
self ._shared_y_axes .join (self , sharey )
506
503
if sharey ._adjustable == 'box' :
507
504
sharey ._adjustable = 'datalim'
508
- # warnings.warn(
509
- # 'shared axes: "adjustable" is being changed to "datalim"')
510
505
self ._adjustable = 'datalim'
511
506
self .set_label (label )
512
507
self .set_figure (fig )
@@ -2341,18 +2336,9 @@ def draw(self, renderer=None, inframe=False):
2341
2336
for spine in six .itervalues (self .spines ):
2342
2337
artists .remove (spine )
2343
2338
2344
- if self .axison and not inframe :
2345
- if self ._axisbelow is True :
2346
- self .xaxis .set_zorder (0.5 )
2347
- self .yaxis .set_zorder (0.5 )
2348
- elif self ._axisbelow is False :
2349
- self .xaxis .set_zorder (2.5 )
2350
- self .yaxis .set_zorder (2.5 )
2351
- else :
2352
- # 'line': above patches, below lines
2353
- self .xaxis .set_zorder (1.5 )
2354
- self .yaxis .set_zorder (1.5 )
2355
- else :
2339
+ self .xaxis .set_zorder (self .get_zorder ())
2340
+ self .yaxis .set_zorder (self .get_zorder ())
2341
+ if not self .axison and inframe :
2356
2342
for _axis in self ._get_axis_list ():
2357
2343
artists .remove (_axis )
2358
2344
@@ -2425,34 +2411,39 @@ def get_renderer_cache(self):
2425
2411
# Axes rectangle characteristics
2426
2412
2427
2413
def get_frame_on (self ):
2428
- """
2429
- Get whether the axes rectangle patch is drawn
2430
- """
2414
+ """Get whether the axes rectangle patch is drawn."""
2431
2415
return self ._frameon
2432
2416
2433
2417
def set_frame_on (self , b ):
2434
- """
2435
- Set whether the axes rectangle patch is drawn
2418
+ """Set whether the axes rectangle patch is drawn.
2436
2419
2437
2420
ACCEPTS: [ *True* | *False* ]
2438
2421
"""
2439
2422
self ._frameon = b
2440
2423
self .stale = True
2441
2424
2442
2425
def get_axisbelow (self ):
2443
- """
2444
- Get whether axis below is true or not
2445
- """
2426
+ """Get whether axis below is true or not."""
2446
2427
return self ._axisbelow
2447
2428
2448
2429
def set_axisbelow (self , b ):
2449
- """
2450
- Set whether the axis ticks and gridlines are above or below most
2451
- artists
2430
+ """Set the zorder for the axes ticks and gridlines.
2431
+
2432
+ ``True`` corresponds to a zorder of 0.5, ``False`` to a zorder of 2.5,
2433
+ and ``"line"`` to a zorder of 1.5.
2452
2434
2453
2435
ACCEPTS: [ *True* | *False* | 'line' ]
2454
2436
"""
2455
- self ._axisbelow = validate_axisbelow (b )
2437
+ self ._axisbelow = axisbelow = validate_axisbelow (b )
2438
+ if axisbelow is True :
2439
+ zorder = 0.5
2440
+ elif axisbelow is False :
2441
+ zorder = 2.5
2442
+ elif axisbelow == "line" :
2443
+ zorder = 1.5
2444
+ else :
2445
+ raise ValueError ("Unexpected axisbelow value" )
2446
+ self .set_zorder (zorder )
2456
2447
self .stale = True
2457
2448
2458
2449
@docstring .dedent_interpd
@@ -2481,6 +2472,8 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
2481
2472
2482
2473
%(Line2D)s
2483
2474
2475
+ Note that the will be drawn according to the axes' zorder and not its
2476
+ own.
2484
2477
"""
2485
2478
if len (kwargs ):
2486
2479
b = True
0 commit comments