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

stat_bin2d error with text geom when using transformed scales #2366

Closed
beansprout88 opened this Issue Dec 9, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@beansprout88

beansprout88 commented Dec 9, 2017

I am encountering an issue with label placement with the stat_bin2d function when using a transformed axis such as log or sqrt. Essentially the labels are misplaced or missing in the latter case, as shown below

This gives a correct placement of labels showing the number of data points in each quadrant:

df <- data.frame(rnorm(1000) + 5, rnorm(1000) + 5)
colnames(df) <- c('x', 'y')

ggplot(df) +
  aes(x = x, y = y) +
  geom_point() +
  geom_vline(xintercept = 5) + geom_hline(yintercept = 5) +
  stat_bin2d(geom = 'label', 
             aes(label = ..count..), 
             breaks = list(x = c(1, 5, 20), y = c(1, 5, 20)), 
             fill = 'white')

image

However the addition of scale_x_log10() causes all of the labels to be lost. Depending on the exact axes, sometimes only some labels are lost. The numbers may also change indicating that the bins are incorrect.
image

has2k1 added a commit to has2k1/ggplot2 that referenced this issue Dec 11, 2017

Fix breaks for bin & bin2d stats for trans scales
The issue only was only about `stat_bin_2d`, but `stat_bin`
suffered the same slight.

Fixes tidyverse#2366

has2k1 added a commit to has2k1/ggplot2 that referenced this issue Dec 11, 2017

Fix breaks for bin & bin2d stats for trans scales
The issue only was only about `stat_bin_2d`, but `stat_bin`
suffered the same slight.

Fixes tidyverse#2366

@hadley hadley closed this in #2367 Dec 12, 2017

hadley added a commit that referenced this issue Dec 12, 2017

Fix breaks for bin & bin2d stats for trans scales (#2367)
The issue only was only about `stat_bin_2d`, but `stat_bin`
suffered the same slight.

Fixes #2366

@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.