Closed tjmahr closed 7 years ago
Yes, stat_joy
makes a joint density estimate, which may or may not be desired. You can recover the old behavior by using stat_density
:
ggplot(iris_long) +
aes(x = value, y = Species, height = ..density..) +
geom_joy(rel_min_height = 0.01, stat="density") +
facet_wrap("variable", scales = "free_x")
Note that this graph looks different than yours because in mine the area under each curve is the same within each panel. (It's not necessarily the same across panels.)
This probably needs to be added to the documentation somewhere.
I've added a note about this issue to the documentation of geom_joy()
.
In the latest version on github master, this should now work with the default stat_joy
.
library(dplyr)
iris_long <- iris %>%
tidyr::gather(variable, value, -Species)
library(ggjoy)
ggplot(iris_long) +
aes(x = value, y = Species) +
geom_joy(rel_min_height = 0.01) +
facet_wrap("variable", scales = "free_x")
Density estimates are still made jointly within each panel, but separately among panels.
The
facet_
functions allow the x and y limits to vary within each panel by using thescales
argument.ggjoy used to respect the per-panel free scales, but in the most recent update, it lost this ability.