r - 添加注释文本以使用 as.Date x 轴进行绘图
问题描述
我见过类似的问题,但答案似乎对我的图表没有帮助。我在这里有一个情节:
n_cases_plot <- ggplot(data = n_cases, aes(x = month, y = n_cases, color
= "#668cff", fill = "#668cff")) +
geom_bar(stat = "identity") +
theme(panel.background = element_blank()) +
ggtitle("Number of Parole Cases Heard by Month") +
theme(plot.title = element_text(hjust = 0.4)) +
guides(fill=FALSE) +
guides(color = FALSE) +
xlab("") +
ylab("") +
theme(text=element_text(size=12, family="Georgia")) +
geom_smooth(method = lm, se = FALSE, aes(color = "lightskyblue1")) +
theme(panel.background = element_rect(fill = "moccasin")) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
我正在尝试添加文本以将下降描述为 -29%。我试过添加
+ annotate("text", x = 4, y = 10, "-29%")
但我不断收到错误
Error: Invalid input: date_trans works with objects of class Date only