Plot multiple series of data into a single bagplot with R

前端 未结 1 477
灰色年华
灰色年华 2021-01-06 01:25

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

相关标签:
1条回答
  • 2021-01-06 01:47

    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

    0 讨论(0)
提交回复
热议问题