一个 Select 是在第一个上面画一个蓝色轮廓的透明条形图,我用stat="summary"
和fun=sum
来计算每个a
的总数:
library(ggplot2)
test <- as.data.frame(cbind(a = c(1, 1, 2, 3), b = 1:4, c = as.character(1:4)))
ggplot(test) +
geom_bar(aes(x = a, y = b, fill = c), stat = "identity") +
geom_bar(
aes(x = a, y = b, group = a),
colour = "blue",
stat = "summary", fun = sum,
fill = "transparent"
)