@@ -533,7 +533,65 @@ def _preprocess(self, *args, **kwargs):
533533 return _preprocess .__get__ (canvas ) # ...I don't get it either
534534
535535
536- def _panels_kwargs (
536+ def _get_panelargs (
537+ side , share = None , width = None , space = None ,
538+ filled = False , figure = False ):
539+ """Return default properties for new axes and figure panels."""
540+ s = side [0 ]
541+ if s not in 'lrbt' :
542+ raise ValueError (f'Invalid panel spec { side !r} .' )
543+ space = space_user = units (space )
544+ if share is None :
545+ share = (not filled )
546+ if width is None :
547+ if filled :
548+ width = rc ['colorbar.width' ]
549+ else :
550+ width = rc ['subplots.panelwidth' ]
551+ width = units (width )
552+ if space is None :
553+ key = ('wspace' if s in 'lr' else 'hspace' )
554+ pad = (rc ['axpad' ] if figure else rc ['panelpad' ])
555+ space = _get_space (key , share , pad = pad )
556+ return share , width , space , space_user
557+
558+
559+ def _get_space (key , share = 0 , pad = None ):
560+ """Return suitable default spacing given a shared axes setting."""
561+ if key == 'left' :
562+ space = units (_notNone (pad , rc ['subplots.pad' ])) + (
563+ rc ['ytick.major.size' ] + rc ['ytick.labelsize' ]
564+ + rc ['ytick.major.pad' ] + rc ['axes.labelsize' ]) / 72
565+ elif key == 'right' :
566+ space = units (_notNone (pad , rc ['subplots.pad' ]))
567+ elif key == 'bottom' :
568+ space = units (_notNone (pad , rc ['subplots.pad' ])) + (
569+ rc ['xtick.major.size' ] + rc ['xtick.labelsize' ]
570+ + rc ['xtick.major.pad' ] + rc ['axes.labelsize' ]) / 72
571+ elif key == 'top' :
572+ space = units (_notNone (pad , rc ['subplots.pad' ])) + (
573+ rc ['axes.titlepad' ] + rc ['axes.titlesize' ]) / 72
574+ elif key == 'wspace' :
575+ space = (units (_notNone (pad , rc ['subplots.axpad' ]))
576+ + rc ['ytick.major.size' ] / 72 )
577+ if share < 3 :
578+ space += (rc ['ytick.labelsize' ] + rc ['ytick.major.pad' ]) / 72
579+ if share < 1 :
580+ space += rc ['axes.labelsize' ] / 72
581+ elif key == 'hspace' :
582+ space = units (_notNone (pad , rc ['subplots.axpad' ])) + (
583+ rc ['axes.titlepad' ] + rc ['axes.titlesize' ]
584+ + rc ['xtick.major.size' ]) / 72
585+ if share < 3 :
586+ space += (rc ['xtick.labelsize' ] + rc ['xtick.major.pad' ]) / 72
587+ if share < 0 :
588+ space += rc ['axes.labelsize' ] / 72
589+ else :
590+ raise KeyError (f'Invalid space key { key !r} .' )
591+ return space
592+
593+
594+ def _get_panelargs (
537595 side , share = None , width = None , space = None ,
538596 filled = False , figure = False ):
539597 """Converts global keywords like `space` and `width` to side-local
0 commit comments