-
Notifications
You must be signed in to change notification settings - Fork 2.1k
stat_binhex
hexagons appear extremely stretched if all data points fall in a single bin on y dimension
#4463
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
Comments
for stat_binhex the provided limits will be used for computing the ybns ybnds <- hex_bounds(y, binwidth[2]) what output do you expect? you might want stat count where you are simply counting how many y at each unique x position |
Something is definitely wrong when the variation in the data is less than the bin width in that direction. Even if library(tidyverse)
set.seed(1234)
data <- tibble(
x = rnorm(1000, 20, 20),
y1 = rnorm(1000, 0, 2),
y2 = rnorm(1000, 0, .2)
)
data %>%
ggplot(aes(x = x, y = y1)) +
stat_binhex() +
scale_x_continuous(limits = c(-100, 100)) +
scale_y_continuous(limits = c(-100, 100)) data %>%
ggplot(aes(x = x, y = y2)) +
stat_binhex() +
scale_x_continuous(limits = c(-100, 100)) +
scale_y_continuous(limits = c(-100, 100)) data %>%
ggplot(aes(x = x, y = y1)) +
stat_binhex(binwidth = c(5, 5)) +
scale_x_continuous(limits = c(-100, 100)) +
scale_y_continuous(limits = c(-100, 100)) data %>%
ggplot(aes(x = x, y = y2)) +
stat_binhex(binwidth = c(5, 5)) +
scale_x_continuous(limits = c(-100, 100)) +
scale_y_continuous(limits = c(-100, 100)) # without limits
data %>%
ggplot(aes(x = x, y = y2)) +
stat_binhex() data %>%
ggplot(aes(x = x, y = y2)) +
stat_binhex(binwidth = c(5, 5)) Created on 2021-05-05 by the reprex package (v1.0.0) |
My previous post wasn't entirely correct. Manually setting the bin height does work when limits aren't set. I just had picked a poor value in my previous example. library(tidyverse)
set.seed(1234)
data <- tibble(
x = rnorm(1000, 20, 20),
y1 = rnorm(1000, 0, 2),
y2 = rnorm(1000, 0, .2)
)
data %>%
ggplot(aes(x = x, y = y2)) +
stat_binhex(binwidth = c(5, 0.08)) Created on 2021-05-05 by the reprex package (v1.0.0) |
Potentially related #4580 ? |
Fixed by #4671 |
If all data points are in a single bin on the y axis (e.g. if they are all equal to 0) the hexagons appear extremely stretched vertically.
Minimal reprex:
The text was updated successfully, but these errors were encountered: