简体   繁体   中英

Geom_boxplot doesn't match base R boxplots

The boxplot in question is highlighted in yellow. The bottom whisker is missing. What's going on?

Base R:

par(cex.axis=0.7)
par(las=1)
boxplot(CONC ~ BALC + DOSE, data = Z3,
         at = c(1:3, 5:7, 9:11), col = 'white',pch=19,xlab=" ", ylab="XXX",
        names='')
par(new=TRUE)
beeswarm(CONC ~ BALC + DOSE, data = Z3,
         at = c(1:3, 5:7, 9:11), col = 'black',pch=19,xlab="XXX", ylab="XXX",
         labels = c("39 mg \n 1st", "39 mg \n 2nd", "39 mg \n 3rd Tertile", 
                    "60 mg \n 1st", "60 mg \n 2nd", "60 mg \n 3rd Tertile", 
                    "90 mg \n 1st", "90 mg \n 2nd", "90 mg \n 3rd Tertile")')

ggplot:

ggplot(data=Z3, aes(x=factor(DOSE), y=CONC, col=BALC)) +
  geom_boxplot(outlier.shape = NA,show.legend = FALSE) +
  labs(x='xxx', y='xxx')+
  theme_Publication() + 
  scale_color_manual(values=c('black','black','black'))+
  theme(plot.title = element_text(size=15))+
  scale_fill_Publication()+
  geom_beeswarm(dodge.width = .8 ,cex=3, aes(shape=BALC), size=2.5)

在此处输入图像描述

在此处输入图像描述

without seeing the dataset its hard to comment but geom error bar might work

something like this

ggplot(data=Z3, aes(x=factor(DOSE), y=CONC, col=BALC)) +
  stat_boxplot(geom = ''errorbar')+
  geom_boxplot(outlier.shape = NA,show.legend = FALSE) +
  labs(x='xxx', y='xxx')+
  theme_Publication() + 
  scale_color_manual(values=c('black','black','black'))+
  theme(plot.title = element_text(size=15))+
  scale_fill_Publication()+
  geom_beeswarm(dodge.width = .8 ,cex=3, aes(shape=BALC), size=2.5)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM