Edit individual ggplots in GGally::ggpairs: How do I have the density plot not filled in ggpairs?

前端 未结 1 1682
臣服心动
臣服心动 2020-12-16 22:13

With

library(GGally)

data(diamonds, package=\"ggplot2\")
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),]

# Custom Example
ggpairs(
 diamonds.         


        
相关标签:
1条回答
  • 2020-12-16 22:55

    The answer to the question can be found on https://cran.r-project.org/web/packages/GGally/vignettes/ggpairs.html (archived here)

    ggally_mysmooth <- function(data, mapping, ...){
      ggplot(data = data, mapping=mapping) +
        geom_density(mapping = aes_string(color="cut"), fill=NA)
    }
    ggpairs(
      diamonds.samp[,1:5],
      mapping = aes(color = cut),
      upper = list(continuous = wrap("density", alpha = 0.5), combo = "box"),
      lower = list(continuous = wrap("points", alpha = 0.3), combo = wrap("dot", alpha = 0.4)),
      diag = list(continuous = ggally_mysmooth),
      title = "Diamonds"
    )
    

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