@@ -678,7 +678,7 @@ def get_window_extent(self, *args, **kwargs):
678678 """
679679 return self .bbox
680680
681- def suptitle (self , t , * , x = .5 , y = .98 , * *kwargs ):
681+ def suptitle (self , t , ** kwargs ):
682682 """
683683 Add a centered title to the figure.
684684
@@ -732,6 +732,11 @@ def suptitle(self, t, *, x=.5, y=.98, **kwargs):
732732
733733 >>> fig.suptitle('This is the figure title', fontsize=12)
734734 """
735+ manual_position = ('x' in kwargs or 'y' in kwargs )
736+
737+ x = kwargs .pop ('x' , 0.5 )
738+ y = kwargs .pop ('y' , 0.98 )
739+
735740 if ('horizontalalignment' not in kwargs ) and ('ha' not in kwargs ):
736741 kwargs ['horizontalalignment' ] = 'center'
737742 if ('verticalalignment' not in kwargs ) and ('va' not in kwargs ):
@@ -751,19 +756,22 @@ def suptitle(self, t, *, x=.5, y=.98, **kwargs):
751756 sup .remove ()
752757 else :
753758 self ._suptitle = sup
754- if self ._layoutbox is not None :
755- # assign a layout box to the suptitle...
756- figlb = self ._layoutbox
757- self ._suptitle ._layoutbox = layoutbox .LayoutBox (
758- parent = figlb ,
759- name = figlb .name + '.suptitle' )
760- for child in figlb .children :
761- if not (child == self ._suptitle ._layoutbox ):
762- w_pad , h_pad , wspace , hspace = \
763- self .get_constrained_layout_pads (
764- relative = True )
765- layoutbox .vstack ([self ._suptitle ._layoutbox , child ],
766- padding = h_pad * 2. , strength = 'required' )
759+ self ._suptitle ._layoutbox = None
760+ if self ._layoutbox is not None and not manual_position :
761+ w_pad , h_pad , wspace , hspace = \
762+ self .get_constrained_layout_pads (relative = True )
763+ figlb = self ._layoutbox
764+ self ._suptitle ._layoutbox = layoutbox .LayoutBox (
765+ parent = figlb , artist = self ._suptitle ,
766+ name = figlb .name + '.suptitle' )
767+ # stack the suptitle on top of all the children.
768+ # Some day this should be on top of all the children in the
769+ # gridspec only.
770+ for child in figlb .children :
771+ if child is not self ._suptitle ._layoutbox :
772+ layoutbox .vstack ([self ._suptitle ._layoutbox ,
773+ child ],
774+ padding = h_pad * 2. , strength = 'required' )
767775 self .stale = True
768776 return self ._suptitle
769777
0 commit comments