@@ -281,8 +281,6 @@ def _suplabels(self, t, info, **kwargs):
281281 Additional kwargs are `matplotlib.text.Text` properties.
282282 """
283283
284- suplab = getattr (self , info ['name' ])
285-
286284 x = kwargs .pop ('x' , None )
287285 y = kwargs .pop ('y' , None )
288286 if info ['name' ] in ['_supxlabel' , '_suptitle' ]:
@@ -294,29 +292,24 @@ def _suplabels(self, t, info, **kwargs):
294292 if y is None :
295293 y = info ['y0' ]
296294
297- if 'horizontalalignment' not in kwargs and 'ha' not in kwargs :
298- kwargs ['horizontalalignment' ] = info ['ha' ]
299- if 'verticalalignment' not in kwargs and 'va' not in kwargs :
300- kwargs ['verticalalignment' ] = info ['va' ]
301- if 'rotation' not in kwargs :
302- kwargs ['rotation' ] = info ['rotation' ]
295+ kwargs = cbook .normalize_kwargs (kwargs , Text )
296+ kwargs .setdefault ('horizontalalignment' , info ['ha' ])
297+ kwargs .setdefault ('verticalalignment' , info ['va' ])
298+ kwargs .setdefault ('rotation' , info ['rotation' ])
303299
304300 if 'fontproperties' not in kwargs :
305- if 'fontsize' not in kwargs and 'size' not in kwargs :
306- kwargs ['size' ] = mpl .rcParams [info ['size' ]]
307- if 'fontweight' not in kwargs and 'weight' not in kwargs :
308- kwargs ['weight' ] = mpl .rcParams [info ['weight' ]]
301+ kwargs .setdefault ('fontsize' , mpl .rcParams [info ['size' ]])
302+ kwargs .setdefault ('fontweight' , mpl .rcParams [info ['weight' ]])
309303
310- sup = self . text ( x , y , t , ** kwargs )
304+ suplab = getattr ( self , info [ 'name' ] )
311305 if suplab is not None :
312306 suplab .set_text (t )
313307 suplab .set_position ((x , y ))
314- suplab .update_from (sup )
315- sup .remove ()
308+ suplab .set (** kwargs )
316309 else :
317- suplab = sup
310+ suplab = self .text (x , y , t , ** kwargs )
311+ setattr (self , info ['name' ], suplab )
318312 suplab ._autopos = autopos
319- setattr (self , info ['name' ], suplab )
320313 self .stale = True
321314 return suplab
322315
0 commit comments