Plot multiple series of data into a single bagplot with R

爷,独闯天下 提交于 2019-11-30 22:58:50

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!