我正在尝试在躲避的geom_bar图上添加数据标签。我知道参数:position = position_dodge(0.9)。但是,由于某种原因,这对我不起作用。谁能解释,我在做什么错?
我的代码:
data_test <- data.frame(Country = c(rep("Poland",5), rep("Europe", 5)),
Year = c(rep(c(2014, 2015, 2016, 2017, 2018),2)),
value = c(0.38, 0.34, 0.38, 0.34, 0.51, 0.41, 0.40, 0.42, 0.33, 0.45))
ggplot(data_test) +
geom_bar(aes(Year, value, fill = Country),
position = "dodge", stat = "identity", width = 0.75) +
geom_text(aes(label = scales::percent(round((value), digits = 2)),
x = Year, y = value + 0.05),
size = 5, position = position_dodge(width = 0.9))