Skip to content

Make sure tiles that runs outside the scale limits are removed #3547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2019

Conversation

thomasp85
Copy link
Member

@thomasp85 thomasp85 commented Oct 1, 2019

Fixes #3539

Prior to this tiles in geom_raster where not removed if they felt outside the scale limits resulting in a squeezing of the raster (it would keep all "pixels" but only occupy the area of the pixels inside the scale limits). This PR fixes it by updating the non_missing_aes field to include xmin, xmax, ymin, and ymax

@thomasp85 thomasp85 added this to the ggplot2 3.3.0 milestone Oct 1, 2019
@thomasp85 thomasp85 requested a review from clauswilke October 1, 2019 11:50
@thomasp85 thomasp85 changed the title Fix #3539 Make sure tiles that runs outside the scale limits are removed Make sure tiles that runs outside the scale limits are removed Oct 1, 2019
@thomasp85 thomasp85 requested a review from karawoo December 13, 2019 09:20
Copy link
Member

@karawoo karawoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Instead of squishing the image it drops the bottom row of tiles and warns about the removed data, which is the correct behavior.

dat <- expand.grid(x = seq(-2, 2, by = 1), y = seq(-2, 2, by = 1))
dat$val <- (1:nrow(dat))/nrow(dat)

ggplot() +
  geom_raster(data = dat, aes(x = x, y = y, fill = val)) +
  geom_hline(yintercept = 0) + geom_vline(xintercept = 0) +
  scale_x_continuous(limits = c(-2.5, 2.5)) + scale_y_continuous(limits = c(-2,2.5))
#> Warning: Removed 5 rows containing missing values (geom_raster).

Created on 2019-12-16 by the reprex package (v0.3.0)

@thomasp85 thomasp85 merged commit 9f0fc2d into tidyverse:master Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strange interaction of geom_raster and scale_{x,y}_continuous
2 participants