Skip to content

Commit

Permalink
Fix geom_label boxstyle parameter
Browse files Browse the repository at this point in the history
fixes #779
  • Loading branch information
has2k1 committed May 6, 2024
1 parent 470c1d2 commit 0b5478a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
6 changes: 6 additions & 0 deletions doc/changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Changelog
## v0.13.6
(not-yet-released)

### Bug Fixes

- Fixed [](:class:`~plotnine.geom_label`) to work with a `boxstyle` of any
following `square`, `circle`, `darrow`, `larrow`, `rarrow`, `roundtooth`
or `sawtooth`.({{< issue 779 >}})

### Enhancements

- Stopped spurious warnings of the form ``PlotnineWarning: Failed to apply
Expand Down
21 changes: 6 additions & 15 deletions plotnine/geoms/geom_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,13 @@ def draw_group(
fill = [list(fill)] * len(data["x"])
plot_data["facecolor"] = fill

if params["boxstyle"] in ("round", "round4"):
boxstyle = (
f"{params['boxstyle']},"
f"pad={params['label_padding']},"
f"rounding_size={params['label_r']}"
)
tokens = [params["boxstyle"], f"pad={params['label_padding']}"]
if params["boxstyle"] in {"round", "round4"}:
tokens.append(f"rounding_size={params['label_r']}")
elif params["boxstyle"] in ("roundtooth", "sawtooth"):
boxstyle = (
f"{params['boxstyle']},"
f"pad={params['label_padding']},"
f"tooth_size={params['tooth_size']}"
)
else:
boxstyle = (
f"{params['boxstyle']}," f"pad={params['label_padding']},"
)
tokens.append(f"tooth_size={params['tooth_size']}")

boxstyle = ",".join(tokens)
bbox = {"linewidth": params["label_size"], "boxstyle": boxstyle}
else:
bbox = {}
Expand Down

0 comments on commit 0b5478a

Please sign in to comment.