Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c54baa

Browse files
committed
Create Texts directly with all kwargs
1 parent dba2d7b commit 2c54baa

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
@@ -699,29 +699,29 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
699699
700700
>>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
701701
"""
702-
default = {
702+
if fontdict is None:
703+
fontdict = {}
704+
705+
effective_kwargs = {
703706
'verticalalignment': 'baseline',
704707
'horizontalalignment': 'left',
705708
'transform': self.transData,
706-
'clip_on': False}
709+
'clip_on': False,
710+
**fontdict,
711+
**kwargs,
712+
}
707713

708714
# At some point if we feel confident that TextWithDash
709715
# is robust as a drop-in replacement for Text and that
710716
# the performance impact of the heavier-weight class
711717
# isn't too significant, it may make sense to eliminate
712718
# the withdash kwarg and simply delegate whether there's
713719
# a dash to TextWithDash and dashlength.
720+
714721
if withdash:
715-
t = mtext.TextWithDash(
716-
x=x, y=y, text=s)
722+
t = mtext.TextWithDash(x, y, text=s, **effective_kwargs)
717723
else:
718-
t = mtext.Text(
719-
x=x, y=y, text=s)
720-
721-
t.update(default)
722-
if fontdict is not None:
723-
t.update(fontdict)
724-
t.update(kwargs)
724+
t = mtext.Text(x, y, text=s, **effective_kwargs)
725725

726726
t.set_clip_path(self.patch)
727727
self._add_text(t)

0 commit comments

Comments
 (0)