@@ -386,6 +386,30 @@ class ThetaAxis(maxis.XAxis):
386386 axis_name = 'theta' #: Read-only name identifying the axis.
387387 _tick_class = ThetaTick
388388
389+ def _update_label_position (self , renderer ):
390+ """
391+ Update the label position based on the bounding box enclosing
392+ all the ticklabels and axis spine
393+ """
394+ if not self ._autolabelpos :
395+ return
396+
397+ # get bounding boxes for this axis and any siblings
398+ # that have been set by `fig.align_xlabels()`
399+ xbboxes , xbboxes2 = self ._get_tick_boxes_siblings (renderer = renderer )
400+ ybboxes , ybboxes2 = self .axes .yaxis ._get_tick_boxes_siblings (renderer = renderer )
401+ # Union with extents of the bottom spine if present, of the axes otherwise.
402+ bbox = mtransforms .Bbox .union ([
403+ * xbboxes , * xbboxes2 , * ybboxes , * ybboxes2 ,
404+ self .axes .spines .get (self .label_position , self .axes ).get_window_extent ()])
405+
406+ x , y = self .label .get_position ()
407+ if self .label_position == 'bottom' :
408+ y = bbox .y0 - self .labelpad * self .get_figure (root = True ).dpi / 72
409+ else :
410+ y = bbox .y1 + self .labelpad * self .get_figure (root = True ).dpi / 72
411+ self .label .set_position ((x , y ))
412+
389413 def _wrap_locator_formatter (self ):
390414 self .set_major_locator (ThetaLocator (self .get_major_locator ()))
391415 self .set_major_formatter (ThetaFormatter ())
@@ -679,6 +703,30 @@ def __init__(self, *args, **kwargs):
679703 super ().__init__ (* args , ** kwargs )
680704 self .sticky_edges .y .append (0 )
681705
706+ def _update_label_position (self , renderer ):
707+ """
708+ Update the label position based on the bounding box enclosing
709+ all the ticklabels and axis spine
710+ """
711+ if not self ._autolabelpos :
712+ return
713+
714+ # get bounding boxes for this axis and any siblings
715+ # that have been set by `fig.align_xlabels()`
716+ xbboxes , xbboxes2 = self ._get_tick_boxes_siblings (renderer = renderer )
717+ ybboxes , ybboxes2 = self .axes .xaxis ._get_tick_boxes_siblings (renderer = renderer )
718+ # Union with extents of the linked spine if present, of the axes otherwise.
719+ bbox = mtransforms .Bbox .union ([
720+ * xbboxes , * xbboxes2 , * ybboxes , * ybboxes2 ,
721+ self .axes .spines .get (self .label_position , self .axes ).get_window_extent ()])
722+
723+ x , y = self .label .get_position ()
724+ if self .label_position == 'left' :
725+ x = bbox .x0 - self .labelpad * self .get_figure (root = True ).dpi / 72
726+ else :
727+ x = bbox .x1 + self .labelpad * self .get_figure (root = True ).dpi / 72
728+ self .label .set_position ((x , y ))
729+
682730 def _wrap_locator_formatter (self ):
683731 self .set_major_locator (RadialLocator (self .get_major_locator (),
684732 self .axes ))
0 commit comments