【发布时间】:2015-09-13 18:19:39
【问题描述】:
我有以下图表:
library(ggplot2)
library(scales)
library(magrittr)
df1 <-
structure(
list(
x = structure(
1:5, .Label = c("5", "4", "3", "2",
"1"), class = "factor"
), y = c(
0.166666666666667, 0.361111111111111,
0.0833333333333333, 0.222222222222222, 0.291666666666667
)
), .Names = c("x",
"y"), row.names = c(NA,-5L), class = c("tbl_df", "tbl", "data.frame"), drop = TRUE
)
df1 %>% ggplot(aes(x , y )) + geom_bar(stat = "identity") +
scale_y_continuous(labels = percent)
我想在 5 和 1 下方添加两行注释,粗体文本。例如,“最高\nvalue”低于 5,“最低 \nvalue”低于 1。
我尝试了geom_text,但无法将文本放置在我想要的位置。
【问题讨论】:
-
annotation_custom() 也许?,请查看此链接:docs.ggplot2.org/current/annotation_custom.html