我想在R中的同一个图表上显示几个条形图。我在R中使用了代码barplot ()
,条形图的颜色被选为"white"
并且边框显示在不同的颜色。由于条重叠,因此未正确显示条中的高度差。相反,我想要显示没有任何填充的条形图,方式是图形中显示每个条形的高度。谁能帮帮我呢?
我使用的代码就在这里。
set.seed (123)
N <- 100
ex_200 <- c (0.0777, 0.0512, 0.0572, 0.0611, 0.0668)
ex.fail_200 <- matrix (NA, ncol = N, nrow = length (ex_200))
for (i in 1: length (ex_200)) {
ex.fail_200 [i, ] <- rpois (N, ex_200 [[i]])
}
counts_200 <- apply (ex.fail_200, 1, table)
barplot (counts_200[[1]], space = 0, col = "white", border = "blue",
ylim = c (0, 100))
barplot (counts_200[[2]], space = 0, col = "white" , border = "red",
add = TRUE)
提前致谢。
答案 0 :(得分:3)
您可以使用“透明”作为颜色而不是白色:
barplot (counts_200[[1]], space = 0, col = "transparent", border = "blue",
ylim = c (0, 100))
barplot (counts_200[[2]], space = 0, col = "transparent", border = "red",
add = TRUE)