1
我可以請尋求你的幫助來標記barplot與像下圖GGPLOT2:如何使用ggplot在-ve和+ ve值的條的另一側標註barplot?
我使用下面的代碼,以獲得附加的情節:
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")
我只是想知道如何獲得每個欄上的第二個數字標籤?
謝謝,
不[**這**](http://learnr.wordpress.com/ 2009/06/01/ggplot2-positioning-of-barplot-category-labels /)help? – Arun 2013-02-27 08:55:08
或[** this **](http://stackoverflow.com/questions/11938293/how-to-label-a-barplot-bar-with-positive-and-negative-bars-with-ggplot2) – Arun 2013-02-27 09:00:39
@ Arun是否可以在每個反映該值的欄上添加另一個標籤? – 2013-02-28 01:42:46