我可以寻求您的帮助,用 ggplot2 标记条形图,如下图所示:
我正在使用以下代码来获取附加图:
library(ggplot2)
test <- data.frame(x = c("Moderately Poor", "Deeply Poor", "Deeply & Intensely Poor", "Intensely Poor", "Overall Poverty"), y = c(0.024, -0.046, -0.025, -0.037, -0.083))
test$colour <- ifelse(test$y < 0, "firebrick1", "steelblue")
test$hjust <- ifelse(test$y > 0, 1.03, -0.03)
ggplot(test, aes(x, y, label = x, hjust = hjust)) +
geom_text(aes(y = 0, colour = colour)) +
geom_bar(stat = "identity", aes(fill = colour))
last_plot() + coord_flip() + labs(x = "", y = "") +
scale_x_discrete(breaks = NA) + theme_bw() +
opts(legend.position = "none")
我只是想知道如何在每个条上获得第二个数字标签?
谢谢,