Home > Blockchain >  Can I manually change boxplot color with ggMarginal?
Can I manually change boxplot color with ggMarginal?

Time:06-08

I'm using ggMarginal to make marginal boxplots. Is there a way to manually change the color and/or fill of the boxplots without a grouping variable? I'd like to have different colors on the x boxplot and the y boxplot.

library(tidyverse)
library(ggExtra)

foo <- data.frame(x=rnorm(100,mean=1,sd=1),
                  y=rnorm(100,mean=2,sd=2))


p1 <- ggplot(data = foo,aes(x=x,y=y))   
  geom_point()   coord_equal()
ggMarginal(p1, type="boxplot", size=12)

CodePudding user response:

Provided I have understood you correctly, you can do the following

p1 <- ggplot(data = foo, aes(x = x, y = y))   
    geom_point()   
    coord_equal()
ggMarginal(
    p1, 
    type = "boxplot", 
    size = 12, 
    xparams = list(colour = "blue"),
    yparams = list(colour = "red"))

enter image description here

  • Related