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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#加载绘图包
library(ggplot2)
library(ggprism)
library(reshape)
library(ggpubr)
#数据
df <- data.frame(A = c(1, 2, 3, 4, 5, 6, 8, 12, 13),
B = c(1, 2, 4, 5, 7, 10,5,6,8),
C = c(1, 5, 6, 7, 8, 9, 10, 11, 13),
D = c(1, 2, 5, 8, 10, 13,5,8,6))
df1=melt(df)
colnames(df1)=c("group","value")
# fig.1
p1<-ggplot(df1,aes(x=group,y=value))+
stat_boxplot(geom = "errorbar", width=0.1)+
geom_boxplot(aes(fill=group),
outlier.colour="white")+
geom_jitter(width = 0.2)+
theme_prism(palette = "candy_bright",
base_fontface = "plain",
base_family = "serif",
base_size = 16,
base_line_size = 0.8,
axis_text_angle = 45)+
scale_fill_prism(palette = "candy_bright")+
theme(legend.position="none")
p1
# fig.2
p2<-ggplot( df1, aes(x = group, y=value,color=group,fill=group) ) +
geom_bar(stat="summary",fun=mean,position="dodge")+
stat_summary(fun.data = 'mean_sd', geom = "errorbar", width = 0.3)+
labs(x="Samples",y=NULL)+
theme_prism(palette = "candy_bright",
base_fontface = "plain",
base_family = "serif",
base_size = 16,
base_line_size = 0.8,
axis_text_angle = 45)+
scale_fill_prism(palette = "candy_bright")+
theme(legend.position="none")
p2
# fig.3
p3<-ggplot(df1, aes(x = group, y=value,fill=group))+
geom_violin(trim = T,position = position_dodge(width = 0.1))+
geom_boxplot(alpha=1,outlier.size=0, size=0.3, width=0.2,fill="white")+
stat_summary(fun="mean",geom="point",shape=21, size=2,fill="blue")+
labs(x="Samples",y=NULL)+
theme_prism(palette = "flames",
base_fontface = "plain",
base_family = "serif",
base_size = 16,
base_line_size = 0.8,
axis_text_angle = 45)+
scale_fill_prism(palette = "candy_bright")+
theme(legend.position = 'none')
p3
# fig.4
p4<-ggplot(df) +
geom_segment(aes(x=A, xend=A, y=0, yend=B), color="grey",size=1) +
geom_point( aes(x=A, y=B,color=A), size=4 ) +
theme_prism(palette = "pearl",
base_fontface = "plain",
base_family = "serif",
base_size = 14,
base_line_size = 0.8,
axis_text_angle = 45) +
theme(legend.position = "none") +
ggtitle("Lollipop Chart")
p4
|