Skip to content

Commit 315486e

Browse files
committed
refactor(strip): let the strip_text themeable own text rotation
1 parent 8f27b1d commit 315486e

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

plotnine/_mpl/text.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ def __init__(
2525
ax: Axes,
2626
position: StripPosition,
2727
label: str,
28-
rotation: float,
2928
):
3029
self.position = position
3130
is_oneline = len(label.split("\n")) == 1
3231
kwargs = {
33-
"rotation": rotation,
3432
"transform": ax.transAxes,
3533
"clip_on": False,
3634
"zorder": 3.3,
37-
# Since the text can be rotated, it is simpler to anchor it at
38-
# the center, align it, then do the rotation. Vertically,
39-
# center_baseline places the text in the visual center, but
40-
# only if it is one line. For multiline text, we are better
41-
# off with plain center.
35+
# The strip_text themeable rotates the text. We anchor it at
36+
# the center so that alignment holds under any rotation it
37+
# applies. Vertically, center_baseline places the text in the
38+
# visual center, but only if it is one line. For multiline
39+
# text, we are better off with plain center.
4240
"ha": "center",
4341
"va": "center_baseline" if is_oneline else "center",
4442
"rotation_mode": "anchor",

plotnine/facets/strips.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,13 @@ def draw(self):
5757

5858
from .._mpl.text import StripText
5959

60-
theme = self.theme
61-
targets = theme.targets
60+
targets = self.theme.targets
6261
position = self.position
6362

64-
if position == "top":
65-
rotation = theme.getp(("strip_text_x", "rotation"))
66-
elif position == "right":
67-
rotation = theme.getp(("strip_text_y", "rotation"))
68-
else:
63+
if position not in ("top", "right"):
6964
raise ValueError(f"Unknown position for strip text: {position!r}")
7065

71-
text = StripText(self.ax, position, self.label_info.text(), rotation)
66+
text = StripText(self.ax, position, self.label_info.text())
7267
rect = text.patch
7368

7469
figure = self.facet.plot.figure

0 commit comments

Comments
 (0)