ggplot2脚注 [英] ggplot2 footnote

查看:228
本文介绍了ggplot2脚注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将脚注添加到使用ggplot2创建的情节底部的最佳方法是什么?我尝试过使用这里提到的逻辑组合 http://www.r-bloggers.com/r-good-practice-%E2%80%93-adding-footnotes-to-graphics/ 以及ggplot2注释函数

pre $注解(text,label =Footnote,
x = unit(1, npc) - 单位(2,mm),y =单位(2,mm),
just = c(right,bottom),gp = gpar(cex = 0.7,col = grey(.5)))

但是我收到错误as.data中的错误。 frame.default(x [[i]],可选= TRUE,stringsAsFactors = stringsAsFactors):不能强制class c(unit.arithmetic,unit)放入data.frame中。



  pdf(

filename.pdf,width = 10,height = 6)#打开一个合适的图形设备
print(p)
makeFootnote()#来自上面的网页(使用grid.text; ggplot2基于gri d)
dev.off()


What is the best way to add a footnote to the bottom of a plot created with ggplot2? I've tried using a combination of the logic noted here http://www.r-bloggers.com/r-good-practice-%E2%80%93-adding-footnotes-to-graphics/ as well as the ggplot2 annotate function

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)))

but I am getting the error "Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class c("unit.arithmetic", "unit") into a data.frame".

解决方案

I would use something like that:

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()

这篇关于ggplot2脚注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆