在使用ggplot2创建的绘图底部添加脚注的最佳方法是什么?我尝试过使用这里提到的逻辑组合http://www.r-bloggers.com/r-good-practice-%E2%80%93-adding-footnotes-to-graphics/以及ggplot2注释功能
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)))
Run Code Online (Sandbox Code Playgroud)
但是我收到错误"as.data.frame.default(x [[i]]中的错误,可选= TRUE,stringsAsFactors = stringsAsFactors):不能将类c("unit.arithmetic","unit")强制转换为data.frame".
rcs*_*rcs 12
我会用这样的东西:
pdf("filename.pdf", width=10, height=6) # open an appropriate graphics device
print(p)
makeFootnote() # from webpage above (uses grid.text; ggplot2 is based on grid)
dev.off()
Run Code Online (Sandbox Code Playgroud)
labs(caption = "my caption")
添加脚注:ggplot(mtcars, aes(mpg, wt, colour = cyl)) +
geom_point() +
labs(caption = "(Pauloo, et al. 2017)")
Run Code Online (Sandbox Code Playgroud)