zl程序教程

您现在的位置是:首页 >  其它

当前栏目

条形图以及分组条形图

以及 分组 条形图
2023-06-13 09:13:59 时间

一、条形图

# 实践:绘制人染色体长度分布图
x <- read.csv(file = "homo_length.csv",header = T)
head(x)
x <- x[1:24,] 

barplot(height = x$length)  
barplot(height = x$length,names.arg = x$chr)  
barplot(height = x$length,names.arg = x$chr,las =3)  
barplot(height = x$length,names.arg = x$chr,las =3,col = rainbow(4))  
barplot(height = x$length,names.arg = x$chr,las =3,col = 'red')  
barplot(height = x$length,names.arg = x$chr,las =3,col = c('red','green'))
library(RColorBrewer)  
display.brewer.all()
cols <- brewer.pal(n = 6,name = "RdPu")  
barplot(height = x$length,names.arg = x$chr,col = cols) 
cols <- brewer.pal(n = 6,name = "Dark2")  
barplot(height = x$length,names.arg = x$chr,col = cols) 
cols <- brewer.pal(n = 6,name = "Blues")  
barplot(height = x$length,names.arg = x$chr,col = cols) 
cols <- brewer.pal(n = 6,name = "Set1")
barplot(height = x$length,names.arg = x$chr,col = cols,las=3) 
barplot(height = x$length,names.arg = x$chr,col = cols,horiz = T,las=2) 
par('mar')
barplot(height = x$length,names.arg = x$chr,col = cols,horiz = T,las=2,
        border = F,width = c(1,2),space = 0.1) 
barplot(height = x$length,names.arg = x$chr,las=2,
        border = F,width = c(1,2),space = 1,density = 12,angle = c(45,135))

人染色体长度分布图

二、分组条形图

 #绘制分组条形图
x <- read.csv("sv_distrubution.csv",header = T,row.names = 1)  
head(x) 
#barplot(x)  
barplot(as.matrix(x))  
barplot(t(as.matrix(x)))  
# barplot(t(as.matrix(x)),col = rainbow(4))  
barplot(t(as.matrix(x)),col = brewer.pal(4,name = 'Set2')) 
barplot(t(as.matrix(x)),col = brewer.pal(4,name = 'Set2'),beside = T)  
barplot(t(as.matrix(x)),col = brewer.pal(4,name = 'Set2'),
        horiz = F,density = 30,angle = c(45,135)) 
barplot(t(as.matrix(x)),col = brewer.pal(4,name = 'Set2')) 
barplot(t(as.matrix(x)),col = brewer.pal(4,name = 'Set2'),legend.text = colnames(x),ylim = c(0,800),  
        main = "SV Distribution",xlab="Chromosome Number",ylab="SV Numbers")

堆叠条形图

写在最后:有时间我们会努力更新的。大家互动交流可以前去论坛,地址在下面,复制去浏览器即可访问,弥补下公众号没有留言功能的缺憾。原地址暂未启用(bioinfoer.com)。

sx.voiceclouds.cn

有些板块也可以预设为大家日常趣事的分享等,欢迎大家来提建议。