boxuancui / DataExplorer

Automate Data Exploration and Treatment
http://boxuancui.github.io/DataExplorer/
Other
512 stars 88 forks source link

plot_boxplot() color by group? #167

Closed arbet003 closed 2 years ago

arbet003 commented 2 years ago

Hello,

When using plot_boxplot(), is it possible to color the boxplots by group? I know how to do this in ggplot, see example code below:

library(DataExplorer)
library(tidyverse)

data(mtcars)
mtcars <- mtcars %>% 
  mutate(
    cyl = as.factor(cyl)
  )

# boxplot fill color by cyl
ggplot(data=mtcars, aes(x=cyl, y=hp, fill=cyl))+
  geom_boxplot()

image

When using plot_boxplot(), all of the boxplots are white... how can I fill/color the boxes by a grouping variable ("cyl")?

plot_boxplot(data=mtcars, by="cyl")

image

boxuancui commented 2 years ago

Hi @arbet003 I did not enable coloring for this type of plots, and it is by design. Here, you are already plotting against cyl column, so it will naturally be broken out in the chart. Any additional action (adding color in this case) will be redundant and provide duplicate of information. Just imagine if this is some other dataset with many more categories, it will be very hard to visualize what was meant to.