diff --git a/NEWS.md b/NEWS.md index 61372a1a25..54453eba92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggplot2 (development version) +* `geom_tile()` now correctly recognises missing data in `xmin`, `xmax`, `ymin`, + and `ymax` (@thomasp85 and @sigmapi, #4495) + * `geom_hex()` will now use the binwidth from `stat_bin_hex()` if present, instead of deriving it (@thomasp85, #4580) diff --git a/R/geom-tile.r b/R/geom-tile.r index 41a5b9109c..f1d6bc3bc7 100644 --- a/R/geom-tile.r +++ b/R/geom-tile.r @@ -113,5 +113,10 @@ GeomTile <- ggproto("GeomTile", GeomRect, required_aes = c("x", "y"), + # These aes columns are created by setup_data(). They need to be listed here so + # that GeomRect$handle_na() properly removes any bars that fall outside the defined + # limits, not just those for which x and y are outside the limits + non_missing_aes = c("xmin", "xmax", "ymin", "ymax"), + draw_key = draw_key_polygon )