Closed
Description
The weight should sum to one, ignoring color or fill aesthetics. That was the behavior before as can be seen here: https://stackoverflow.com/questions/20342494/density-of-each-group-of-weighted-geom-density-sum-to-one
In the way that geom_density is now there is no way to make the sum of both areas be equal to one.
Example:
library(ggplot2)
library(ggplot2movies)
m <- ggplot()
m + geom_density(data = movies, aes(rating, weight = votes, colour = factor(Action)))
The plot above is equal to
m + geom_density(data = movies[movies$Action == 0, ], aes(rating, weight = votes/sum(votes)), fill=NA, colour="black") +
geom_density(data = movies[movies$Action == 1, ], aes(rating, weight = votes/sum(votes)), fill=NA, colour="blue")
I would expect a much smaller area for Action == 1 in the first plot, as less than 10% of the movies are action movies.