导入数据
h2disorders <- read.csv("h2disorders.csv",header = T)
[图片上传失败...(image-e034a7-1678690995126)]
绘图
ggplot(h2disorders, aes(fill=facets, x=facets, y= est))+
#geom_segment( aes(x=ph, xend=ph, y=0, yend=est), size = 2, position = position_dodge(width = .9))+
#geom_point(size=25, alpha=1, shape = 21)+
geom_bar(stat = "identity", color = "black", position = "dodge", width = .9, size = 0) +
geom_errorbar(aes(ymin = est-se, ymax = est+se),width = 0.2,position = position_dodge(.9), size = .7)+
theme(legend.direction = "vertical",
legend.position="right",
legend.text = element_text(size=10),
legend.title = element_blank(),
panel.border = element_rect(linetype = 'solid', colour = 'gray',fill = NA),
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.25, linetype = 'solid',
colour = "gray"),
panel.grid.minor = element_line(size = 0.25, linetype = 'solid'),
axis.line.x = element_line(colour = 'gray', size=0.5, linetype='solid'),
axis.line.y = element_line(colour = 'gray', size=0.5, linetype='solid'),
axis.text.y = element_text(size=10, colour="black", family = "sans", angle = 0),
axis.text.x = element_text(size=10, colour="black", family = "sans", angle = 45, hjust = 1),
#axis.text.x = element_blank(),
axis.title= element_text(size=10),
strip.text.x = element_text(size=10, angle = 0),
strip.text.y = element_text(size=10, angle = 0),
plot.title = element_text(size=10, angle = 0),
strip.background = element_rect(colour="black", fill="white"))+
ggtitle("")+
xlab("")+
ylab("Grand estimate")+
#scale_fill_brewer(palette = "BuPu")+
#scale_fill_brewer(palette = 4)+
coord_flip()+
#geom_text(aes(label = k), vjust = 0.5, hjust = 5, size = 10)+
geom_text(aes(y=label, label = k), size = 3)+
#scale_fill_gradient2(low = "#faa300", high = "orange")+
#scale_x_discrete(labels=c("Parent","Teacher","Child"))+
#scale_y_continuous(limits = c(0,.06))+
scale_fill_manual(values = c("dodgerblue3","firebrick1","lightskyblue","orange"),
breaks = c("Family h2","Family c2","Family e2","SNP h2"))+
facet_grid(disorder~., scales = "free", space = "free")+
scale_y_continuous(limits = c(-.1,1.4), breaks = seq(0,1.4,0.2))
如果你要绘制多个类似的图,那么你也可以在后面参数中加入
facet_wrap(facets~., scales = "free")
ENDING!!
往期文章:
1. 最全WGCNA教程(替换数据即可出全部结果与图形)
2. 精美图形绘制教程
小杜的生信筆記 ,主要发表或收录生物信息学的教程,以及基于R的分析和可视化(包括数据分析,图形绘制等);分享感兴趣的文献和学习资料!!