Skip to content

Commit

Permalink
Add 'borderstyle' text() keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Oct 5, 2021
1 parent 53f77b0 commit 25e21c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions proplot/axes/base.py
Expand Up @@ -2891,10 +2891,9 @@ def legend(
@docstring._concatenate_inherited
@docstring._snippet_manager
def text(
self, *args,
border=False, bordercolor='w', borderwidth=2, borderinvert=False,
bbox=False, bboxcolor='w', bboxstyle='round', bboxalpha=0.5, bboxpad=None,
**kwargs
self, *args, border=False, bbox=False,
bordercolor='w', borderwidth=2, borderinvert=False, borderstyle='miter',
bboxcolor='w', bboxstyle='round', bboxalpha=0.5, bboxpad=None, **kwargs
):
"""
Add text to the axes.
Expand All @@ -2919,6 +2918,10 @@ def text(
The color of the text border. Default is ``'w'``.
borderinvert : bool, optional
If ``True``, the text and border colors are swapped.
borderstyle : {'miter', 'round', 'bevel'}, optional
The `line join style \
<https://matplotlib.org/stable/gallery/lines_bars_and_markers/joinstyle.html>`__
used for the border.
bbox : bool, optional
Whether to draw a bounding box around text.
bboxcolor : color-spec, optional
Expand Down Expand Up @@ -2970,6 +2973,7 @@ def text(
'bordercolor': bordercolor,
'borderinvert': borderinvert,
'borderwidth': borderwidth,
'borderstyle': borderstyle,
'bbox': bbox,
'bboxcolor': bboxcolor,
'bboxstyle': bboxstyle,
Expand Down
7 changes: 4 additions & 3 deletions proplot/internals/text.py
Expand Up @@ -34,18 +34,19 @@ def _update_text(text, props=None, **kwargs):
bordercolor = props.pop('bordercolor', 'w')
borderinvert = props.pop('borderinvert', False)
borderwidth = props.pop('borderwidth', 2)
borderstyle = props.pop('borderstyle', 'miter')
if border:
facecolor, bgcolor = text.get_color(), bordercolor
if borderinvert:
facecolor, bgcolor = bgcolor, facecolor
kwargs = {
kw = {
'linewidth': borderwidth,
'foreground': bgcolor,
'joinstyle': 'miter',
'joinstyle': borderstyle,
}
text.set_color(facecolor)
text.set_path_effects(
[mpatheffects.Stroke(**kwargs), mpatheffects.Normal()],
[mpatheffects.Stroke(**kw), mpatheffects.Normal()],
)
elif border is False:
text.set_path_effects(None)
Expand Down

0 comments on commit 25e21c7

Please sign in to comment.