@@ -262,6 +262,28 @@ def _alty_overrides(self):
262
262
self .xaxis .set_visible (False )
263
263
self .patch .set_visible (False )
264
264
265
+ def _apply_axis_sharing (self ):
266
+ """
267
+ Enforce the "shared" axis labels and axis tick labels. If this is
268
+ not called at drawtime, "shared" labels can be inadvertantly turned
269
+ off e.g. when the axis scale is changed.
270
+ """
271
+ for x in 'xy' :
272
+ # "Shared" axis and tick labels
273
+ axis = getattr (self , x + 'axis' )
274
+ share = getattr (self , '_share' + x )
275
+ if share is not None :
276
+ level = (
277
+ 3 if getattr (self , '_share' + x + '_override' )
278
+ else getattr (self .figure , '_share' + x )
279
+ )
280
+ if level > 0 :
281
+ axis .label .set_visible (False )
282
+ if level > 2 :
283
+ axis .set_major_formatter (mticker .NullFormatter ())
284
+ # Enforce no minor ticks labels. TODO: Document?
285
+ axis .set_minor_formatter (mticker .NullFormatter ())
286
+
265
287
def _datex_rotate (self ):
266
288
"""
267
289
Apply default rotation to datetime axis coordinates.
@@ -335,28 +357,6 @@ def _dualy_overrides(self):
335
357
child .set_ylim (nlim , emit = False )
336
358
self ._dualy_cache = (scale , * olim )
337
359
338
- def _hide_labels (self ):
339
- """
340
- Enforce the "shared" axis labels and axis tick labels. If this is
341
- not called at drawtime, "shared" labels can be inadvertantly turned
342
- off e.g. when the axis scale is changed.
343
- """
344
- for x in 'xy' :
345
- # "Shared" axis and tick labels
346
- axis = getattr (self , x + 'axis' )
347
- share = getattr (self , '_share' + x )
348
- if share is not None :
349
- level = (
350
- 3 if getattr (self , '_share' + x + '_override' )
351
- else getattr (self .figure , '_share' + x )
352
- )
353
- if level > 0 :
354
- axis .label .set_visible (False )
355
- if level > 2 :
356
- axis .set_major_formatter (mticker .NullFormatter ())
357
- # Enforce no minor ticks labels. TODO: Document?
358
- axis .set_minor_formatter (mticker .NullFormatter ())
359
-
360
360
def _make_twin_axes (self , * args , ** kwargs ):
361
361
"""
362
362
Return a twin of this axes. This is used for twinx and twiny and was
@@ -1185,7 +1185,7 @@ def draw(self, renderer=None, *args, **kwargs):
1185
1185
# Perform extra post-processing steps
1186
1186
# NOTE: This mimics matplotlib API, which calls identical
1187
1187
# post-processing steps in both draw() and get_tightbbox()
1188
- self ._hide_labels ()
1188
+ self ._apply_axis_sharing ()
1189
1189
self ._altx_overrides ()
1190
1190
self ._alty_overrides ()
1191
1191
self ._dualx_overrides ()
@@ -1197,7 +1197,7 @@ def draw(self, renderer=None, *args, **kwargs):
1197
1197
1198
1198
def get_tightbbox (self , renderer , * args , ** kwargs ):
1199
1199
# Perform extra post-processing steps
1200
- self ._hide_labels ()
1200
+ self ._apply_axis_sharing ()
1201
1201
self ._altx_overrides ()
1202
1202
self ._alty_overrides ()
1203
1203
self ._dualx_overrides ()
0 commit comments