-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
In help(stat_bin), it defines ..ncount.. as "count, scaled to maximum of 1" and ..ndensity.. as "density, scaled to maximum of 1". From this I would expect that:
..ncount.. is ..count.. / max(..count..)
and that
..ndensity.. is ..density.. / max(..density..)
However, the latter is not the case. Instead, ..ndensity.. appears to be ..count.. / max(..density..)
If this is a bug, it looks like it could be fixed with a one line change to R/bin.R (which I'd be happy to submit as a pull request if you want). But if this is the intended behavior, perhaps the documentation could be made more clear.
library(ggplot2)
standard_normal <- data.frame(X = rnorm(1E5, 0, 1))
# ..ndensity.. is ..count.. / max(..density..)
# which is not "density, scaled to a maximum of 1"
ggplot(standard_normal, aes(x = X)) +
geom_freqpoly(aes(y = ..ndensity..), binwidth = 0.2, center = 0, size = 1.5, color = 'black') +
geom_freqpoly(aes(y = ..count../max(..density..)), binwidth = 0.2, center = 0, size = 0, color = 'cyan')Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
