-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple-boxplot.R.txt
49 lines (42 loc) · 2.17 KB
/
multiple-boxplot.R.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library(ggplot2)
library(agricolae)
setwd("")
input1<-read.csv("1.csv",header=TRUE)
input2<-read.csv("2.csv",header=TRUE)
input3<-read.csv("3.csv",header=TRUE)
input4<-read.csv("4.csv",header=TRUE)
input<-read.csv("5.csv",header=TRUE)
model1<-aov(RFU ~ DOC, input1)
LSD1<-LSD.test(model1,"DOC", p.adj="bonferroni")
sig1<-data.frame(row.names(LSD1$groups),LSD1$groups$groups) #第一组显著性
model2<-aov(RFU ~ DOC, input2)
LSD2<-LSD.test(model2,"DOC", p.adj="bonferroni")
sig2<-data.frame(row.names(LSD2$groups),LSD2$groups$groups) #第二组显著性
model3<-aov(RFU ~ DOC, input3)
LSD3<-LSD.test(model3,"DOC", p.adj="bonferroni")
sig3<-data.frame(row.names(LSD3$groups),LSD3$groups$groups) #第三组显著性
model4<-aov(RFU ~ DOC, input4)
LSD4<-LSD.test(model4,"DOC", p.adj="bonferroni")
sig4<-data.frame(row.names(LSD4$groups),LSD4$groups$groups) #第四组显著性
input$Concentration <- factor(input$Concentration)
input$DOC <- factor(input$DOC)
ggplot(input, aes(x = Concentration, y = RFU, color = DOC))+ #箱型图
geom_boxplot() +
labs(x ="Microcystis concentration (cells/mL)", y ="Phycocyanin (RFU)", color = "DOC (mg/L)")+
theme_bw()+
geom_text(aes(x= 0.7, y= 2, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 0.9, y= 2, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 1.1, y= 2, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 1.3, y= 2, label = "a"), inherit.aes = FALSE)+
geom_text(aes(x= 1.7, y= 2, label = "a"), inherit.aes = FALSE)+
geom_text(aes(x= 1.9, y= 2, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 2.1, y= 2, label = "c"), inherit.aes = FALSE)+
geom_text(aes(x= 2.3, y= 2, label = "d"), inherit.aes = FALSE)+
geom_text(aes(x= 2.7, y= 5, label = "a"), inherit.aes = FALSE)+
geom_text(aes(x= 2.9, y= 5, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 3.1, y= 5, label = "c"), inherit.aes = FALSE)+
geom_text(aes(x= 3.3, y= 5, label = "d"), inherit.aes = FALSE)+
geom_text(aes(x= 3.7, y= 20, label = "a"), inherit.aes = FALSE)+
geom_text(aes(x= 3.9, y= 20, label = "b"), inherit.aes = FALSE)+
geom_text(aes(x= 4.1, y= 20, label = "c"), inherit.aes = FALSE)+
geom_text(aes(x= 4.3, y= 20, label = "d"), inherit.aes = FALSE)