You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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')
The text was updated successfully, but these errors were encountered:
I assume the change from density to count in the numerator was unintentional. The new code was later moved from R/stat-bin.r to R/bin.r in this commit.
timgoodman
added a commit
to timgoodman/ggplot2
that referenced
this issue
Nov 6, 2017
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.
The text was updated successfully, but these errors were encountered: