diff --git a/doc/changelog.qmd b/doc/changelog.qmd index 234f3c7ac..83f65fa7d 100644 --- a/doc/changelog.qmd +++ b/doc/changelog.qmd @@ -14,7 +14,9 @@ title: Changelog - Stopped spurious warnings of the form ``PlotnineWarning: Failed to apply `after_scale` modifications to the legend.`` when the `after_scale` - mapping is for another aesthetic. + mapping is for another aestetic. + +- Added `width` and `height` as default aesthetics of [](:class:`~plotnine.geom_tile`). ## v0.13.5 (2024-04-26) diff --git a/plotnine/geoms/geom_tile.py b/plotnine/geoms/geom_tile.py index 2f859bb40..e8c08798e 100644 --- a/plotnine/geoms/geom_tile.py +++ b/plotnine/geoms/geom_tile.py @@ -32,6 +32,8 @@ class geom_tile(geom_rect): "fill": "#333333", "linetype": "solid", "size": 0.1, + "width": None, + "height": None, } REQUIRED_AES = {"x", "y"} DEFAULT_PARAMS = { @@ -44,12 +46,18 @@ def setup_data(self, data: pd.DataFrame) -> pd.DataFrame: try: width = data.pop("width") except KeyError: - width = resolution(data["x"], False) + width = self.aes_params.get( + "width", + resolution(data["x"], False), + ) try: height = data.pop("height") except KeyError: - height = resolution(data["y"], False) + height = self.aes_params.get( + "height", + resolution(data["y"], False), + ) data["xmin"] = data["x"] - width / 2 data["xmax"] = data["x"] + width / 2