我正在尝试从2个txt文件中绘制数据 a.txt

c(1009446997.10134, 2129582.232133, 1684766.791461, 1365519.983193, 
1162969.144628, 963505.413047, 806687.025846, 699778.395938, 
611536.669139, 558664.129031, 495161.162453, 416070.762165, 536345.97118, 
326020.411214, 323119.197493, 301553.888271, 276288.29474, 258147.28339, 
238231.281803, 221602.69459, 206269.189678, 186223.48747, 173136.239386, 
156750.406154, 289750.844258)

b.txt

c(1006311544.86118, 2553892.687953, 2396309.164262, 1797103.229124, 
1435811.705459, 1123438.547316, 907066.016324, 752319.816852, 
633176.19432, 541055.716266, 456756.424805, 554325.764806, 335654.692806, 
320344.048214, 289641.383874, 268214.776278, 253511.851556, 240330.064774, 
231902.956644, 223549.91785, 229045.595197, 275974.717633, 1138710.866504
)

像这样的分组条形图

enter image description here

其中y轴是值本身,x轴是行号 . 请注意,两个文件中的行数不同 .

我正在尝试这个但没有成功

sfs_a<-(scan("a.txt")) #read in the log sfs
sfs_b<-(scan("b.txt")) #read in the log sfs
data <-list(sfs_a,sfs_b)
barplot(data, main="Proportions",
        xlab="Chromossomes", col=c("darkblue","red"), beside=TRUE)

可选的解决方案(但我确定非常愚蠢) .

barplot(rbind(Non_synonymous = sfs_a [-1],Synonymous = c(sfs_wbm [-1],0,0)),legend = TRUE,旁边= TRUE,col = c('red','darkblue'),main =“比例”)

enter image description here