diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 8bb104487702..f4ce4dded35d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -699,11 +699,17 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): >>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5)) """ - default = { + if fontdict is None: + fontdict = {} + + effective_kwargs = { 'verticalalignment': 'baseline', 'horizontalalignment': 'left', 'transform': self.transData, - 'clip_on': False} + 'clip_on': False, + **fontdict, + **kwargs, + } # At some point if we feel confident that TextWithDash # is robust as a drop-in replacement for Text and that @@ -711,17 +717,12 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): # isn't too significant, it may make sense to eliminate # the withdash kwarg and simply delegate whether there's # a dash to TextWithDash and dashlength. + if withdash: - t = mtext.TextWithDash( - x=x, y=y, text=s) + t = mtext.TextWithDash(x, y, text=s) else: - t = mtext.Text( - x=x, y=y, text=s) - - t.update(default) - if fontdict is not None: - t.update(fontdict) - t.update(kwargs) + t = mtext.Text(x, y, text=s) + t.update(effective_kwargs) t.set_clip_path(self.patch) self._add_text(t) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 7cd48ef06b6a..c86292d9ebe5 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1319,7 +1319,8 @@ def __init__(self, multialignment=multialignment, fontproperties=fontproperties, rotation=rotation, - linespacing=linespacing) + linespacing=linespacing, + ) # The position (x,y) values for text and dashline # are bogus as given in the instantiation; they will pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy