如何在使用ggplot2创建的图表底部添加脚注?我已经尝试过结合这里提到的逻辑以及ggplot2的annotate
函数。
p + annotate("text",label="Footnote",
x=unit(1,"npc") - unit(2, "mm"),y=unit(2, "mm"),
just=c("right", "bottom"),gp=gpar(cex= 0.7, col=grey(.5)))
但我收到了以下错误:
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class c("unit.arithmetic", "unit") into a data.frame
ggsave()
,例如pdf("filename.pdf", width=10, height=6); print(p); grid.text(...); dev.off()
。 - rcs