[R] boxplot notch

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Aug 16 15:30:03 CEST 2024


   I don't see anything obviously wrong here. There may be something 
subtle, but we probably won't be able to help without a reproducible 
example ...

On 2024-08-16 9:24 a.m., SIBYLLE STÖCKLI via R-help wrote:
> Dear community
> 
>   
> 
> I tried the following code using geom_boxplot() and notch=TRUE. Does anyone
> know if the command �notch=TRUE� is at the wrong place in my special code
> construct?
> 
>   
> 
> Without notch=TRUE the code provides the planned ggplot.
> 
>   
> 
> Kind regards
> 
> Sibylle
> 
>   
> 
> Code:
> 
>   
> 
> MS1<- MS %>% filter(QI_A!="NA") %>% droplevels()
> 
> MS1$Jahr<-as.factor(MS1$Jahr)
> 
>   
> 
> MS1s <- MS1 %>%
> 
>    group_by(MS1$Jahr, MS1$Bio) %>%
> 
>    summarise(
> 
>      y0 = quantile(QI_A, 0.05),
> 
>      y25 = quantile(QI_A, 0.25),
> 
>      y50 = mean(QI_A),
> 
>      y75 = quantile(QI_A, 0.75),
> 
>      y100 = quantile(QI_A, 0.95))
> 
>   
> 
> MS1s
> 
> colnames(MS1s)[1]<-"Jahr"
> 
> colnames(MS1s)[2]<-"Bio"
> 
> MS1s
> 
>   
> 
> p1<-ggplot(MS1s, aes(Jahr,  fill = as.factor(Bio))) +
> 
>    geom_boxplot(
> 
>      aes(ymin = y0, lower = y25, middle = y50, upper = y75, ymax = y100),
> 
>      stat = "identity", notch=TRUE
> 
>    ) +
> 
>    theme(panel.background = element_blank())+
> 
>    theme(axis.line = element_line(colour = "black"))+
> 
>    theme(axis.text=element_text(size=18))+
> 
>    theme(axis.title=element_text(size=20))+
> 
>    ylab("Anteil BFF an LN [%]") +xlab("Jahr")+
> 
>    scale_color_manual(values=c("red","darkgreen"), labels=c("�LN", "BIO"))+
> 
>    scale_fill_manual(values=c("red","darkgreen"), labels= c("�LN", "BIO"))+
> 
>    theme(legend.title = element_blank())+
> 
>    theme(legend.text=element_text(size=20))
> 
> p1<-p1 + expand_limits(y=c(0, 80))
> 
> p1
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
 > E-mail is sent at my convenience; I don't expect replies outside of 
working hours.



More information about the R-help mailing list