Skip to content
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

Faint lines through colour steps guide segments when even.steps = FALSE #5481

Closed
jimjam-slam opened this issue Oct 13, 2023 · 1 comment · Fixed by #5495
Closed

Faint lines through colour steps guide segments when even.steps = FALSE #5481

jimjam-slam opened this issue Oct 13, 2023 · 1 comment · Fixed by #5495

Comments

@jimjam-slam
Copy link

jimjam-slam commented Oct 13, 2023

This reprex actually comes from the current ggplot2 3.4.4 docs for guide_colorsteps, where it is visible:

df <- expand.grid(X1 = 1:10, X2 = 1:10)
df$value <- df$X1 * df$X2

  p <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))
# By default each bin in the guide is the same size irrespectively of how
# their sizes relate in data space
p + scale_fill_binned(breaks = c(10, 25, 50))

image

# This can be changed with the `even.steps` argument
p + scale_fill_binned(
  breaks = c(10, 25, 50),
  guide = guide_coloursteps(even.steps = FALSE))

image

When I run this code on ggplot 3.4.4, I can't see the faint lines at low-resolution outputs, but if I run, ggsave at, say, width = 1920, height = 1080, units = 'px', or with SVG output, they're definitely visible. Mapping colour to the same variable as fill hides the lines from the tiles themselves but not from the colour bar (unless there's a way to merge the fill and colour guides rather than hiding one?).

@teunbrand
Copy link
Collaborator

The lines in the coloursteps guide (and rectangles in the main panel) appear to be anti-aliasing artifacts from drawing the guide as a series of small rectangles. Anti-aliasing settings depends on the device, so there isn't a lot ggplot2 can do on that front.

However, I don't see why guide_coloursteps() couldn't just draw a single rectangle between limits/breaks, so I'm going to consider this issue a feature request for an option like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants