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
Smallest points are removed from plot #1022
Comments
Wonder if it has something to do with the |
I suspect its rounding by the graphics system - ie the point is 0.45 pixels wide so gets rounded down to 0 |
Possibly, but counting against a rendering issue the problem reproduces in Mac and Windows. It also happens when the ‘max_size’ argument is increased experimentally to giant proportions. |
Ah good point, thanks! d <- data.frame(x = 1:4, y = rep(1, 4), v = 10 ^ (1:4))
ggplot(d, aes(x, y, size=v)) +
geom_point(alpha = 1/3) +
geom_text(aes(label = v), size = 8, col = "red") +
scale_size_area(max_size = 500) +
theme(legend.position = "none") +
xlim(0, 5)
last_plot() %+% d[1:3, ] Looks like the rounding is happening somewhere else |
Oh I bet it's this: scale_map.continuous <- function(scale, x, limits = scale_limits(scale)) {
x <- scale$oob(scale$rescaler(x, from = limits))
# Points are rounded to the nearest 500th, to reduce the amount of
# work that the scale palette must do - this is particularly important
# for colour scales which are rather slow. This shouldn't have any
# perceptual impacts.
x <- round_any(x, 1 / 500)
uniq <- unique(x)
pal <- scale$palette(uniq)
scaled <- pal[match(x, uniq)]
ifelse(!is.na(scaled), scaled, scale$na.value)
} |
This stackoverflow question gives detail.
The smallest points are lost from the plot when data ranges across several orders of magnitude and scale_size_area is being used, I think due to rounding to zero somewhere. The example demonstrates (look for the 10 point):
d = data.frame(x=1:4, y=rep(1,4), v=10^(1:4))
ggplot(d, aes(x, y, size=v)) + geom_point(alpha=.5) + geom_text(aes(label = v), size=8, col='red') +
scale_size_area(max_size = 500) + theme(legend.position = "none")
Mostly not a problem, but can be for some plots - this map of commuter patterns loses points in neighbouring cities (white labels show where points should be).
The text was updated successfully, but these errors were encountered: