Skip to content

Commit 34309f3

Browse files
committed
Add width and height aesthetics to geom_tile
1 parent 0b5478a commit 34309f3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

doc/changelog.qmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ title: Changelog
1414

1515
- Stopped spurious warnings of the form ``PlotnineWarning: Failed to apply
1616
`after_scale` modifications to the legend.`` when the `after_scale`
17-
mapping is for another aesthetic.
17+
mapping is for another aestetic.
18+
19+
- Added `width` and `height` as default aesthetics of [](:class:`~plotnine.geom_tile`).
1820

1921
## v0.13.5
2022
(2024-04-26)

plotnine/geoms/geom_tile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class geom_tile(geom_rect):
3232
"fill": "#333333",
3333
"linetype": "solid",
3434
"size": 0.1,
35+
"width": None,
36+
"height": None,
3537
}
3638
REQUIRED_AES = {"x", "y"}
3739
DEFAULT_PARAMS = {
@@ -44,12 +46,18 @@ def setup_data(self, data: pd.DataFrame) -> pd.DataFrame:
4446
try:
4547
width = data.pop("width")
4648
except KeyError:
47-
width = resolution(data["x"], False)
49+
width = self.aes_params.get(
50+
"width",
51+
resolution(data["x"], False),
52+
)
4853

4954
try:
5055
height = data.pop("height")
5156
except KeyError:
52-
height = resolution(data["y"], False)
57+
height = self.aes_params.get(
58+
"height",
59+
resolution(data["y"], False),
60+
)
5361

5462
data["xmin"] = data["x"] - width / 2
5563
data["xmax"] = data["x"] + width / 2

0 commit comments

Comments
 (0)