Let\'s condsider the bagplot example as included in the aplpack library in R. A bagplot is a bivariate generalisation of a boxplot and therefore gives insight in the distrib
If we modify some of the aplpack::bagplot
code we can make a new geom for ggplot2. Then we can compare groups within a dataset in the usual ggplot2 ways. Here's one example:
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width,
colour = Species, fill = Species)) +
geom_bag() +
theme_minimal()
and we can show the points with the bagplot:
ggplot(iris, aes(Sepal.Length, Sepal.Width,
colour = Species, fill = Species)) +
geom_bag() +
geom_point() +
theme_minimal()
Here's the code for the geom_bag
and modified aplpack::bagplot
function: https://gist.github.com/benmarwick/00772ccea2dd0b0f1745