好奇,如何创建一个只有文本信息的情节.这将基本上是绘图窗口的“打印”.
到目前为止我发现的最好的选择如下:
library(RGraphics) library(gridExtra) text = paste("\n The following is text that'll appear in a plot window.\n"," As you can see,it's in the plot window"," One might imagine useful informaiton here") grid.arrange(splitTextGrob(text))
但是,对于字体类型,大小,对齐等方面,没有任何控制(据我所知).
解决方法
您可以使用基本图形来执行此操作.首先你会想要从绘图窗口中拿走所有的空白:
par(mar = c(0,0))
然后你会绘制一个空的情节:
plot(c(0,1),c(0,ann = F,bty = 'n',type = 'n',xaxt = 'n',yaxt = 'n')
这是一个关于这里发生的事情的指南(使用?plot.default和?par了解更多详细信息):
> ann – 显示Annotoations(设置为FALSE)
> bty – 边框类型(无)
>类型 – 绘图类型(不产生点或线)
> xaxt – x轴类型(无)
> yaxt – y轴类型(无)
现在绘制文字.我拿出了额外的空间,因为他们似乎没有必要.
text(x = 0.5,y = 0.5,paste("The following is text that'll appear in a plot window.\n","As you can see,it's in the plot window\n","One might imagine useful informaiton here"),cex = 1.6,col = "black")
现在恢复默认设置
par(mar = c(5,4,2) + 0.1)
我希望有帮助!