Skip to content

Commit a34c617

Browse files
committed
Create Texts directly with all kwargs
1 parent 03b07fb commit a34c617

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -692,29 +692,29 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
692692
693693
>>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
694694
"""
695-
default = {
695+
if fontdict is None:
696+
fontdict = {}
697+
698+
effective_kwargs = {
696699
'verticalalignment': 'baseline',
697700
'horizontalalignment': 'left',
698701
'transform': self.transData,
699-
'clip_on': False}
702+
'clip_on': False,
703+
**fontdict,
704+
**kwargs,
705+
}
700706

701707
# At some point if we feel confident that TextWithDash
702708
# is robust as a drop-in replacement for Text and that
703709
# the performance impact of the heavier-weight class
704710
# isn't too significant, it may make sense to eliminate
705711
# the withdash kwarg and simply delegate whether there's
706712
# a dash to TextWithDash and dashlength.
713+
707714
if withdash:
708-
t = mtext.TextWithDash(
709-
x=x, y=y, text=s)
715+
t = mtext.TextWithDash(x, y, text=s, **effective_kwargs)
710716
else:
711-
t = mtext.Text(
712-
x=x, y=y, text=s)
713-
714-
t.update(default)
715-
if fontdict is not None:
716-
t.update(fontdict)
717-
t.update(kwargs)
717+
t = mtext.Text(x, y, text=s, **effective_kwargs)
718718

719719
t.set_clip_path(self.patch)
720720
self._add_text(t)

0 commit comments

Comments
 (0)