我正在使用 R 创建多图布局插图,并且能够在其中一个图中创建多行文本框会很方便。
我熟悉使用 Sweave 来组合图像、文本和 R 代码,但是由于各种原因,我需要将其作为在 R 中生成的单页图。因此需要绘制文本框而不是使用 Latex 标记。
现有包中是否有可以执行此操作的函数?如果做不到这一点,任何人都可以建议一种简单的方法来处理这个问题吗?
考虑这种情况:
## Specify the dimensions of the plot
## that we require
win.graph(8,4)
## Two panel layout
layout(matrix(1:2, 1, 2))
par(mar=c(0,0,0,0))
## Left panel shows picture
plot(rep(1:10, each=10), rep(1:10, times=10),
col=rainbow(100), pch=20, cex=5)
## Right panel discusses the data
plot.default(c(0,100), c(0,100), type="n", axes=FALSE,
ylab="", xlab="")
text(20, 30, "It would be great if this text box\n
could handle word wrap, and ideally given the size\n
of the font (i.e. the cex parameter) and the area\n
of the plot it should be able to do this dynamically,\n
without requiring the newline characters I am\n
manually inserting. Ability to control the line\n
height would also be nice.\n
Am I dreaming?", cex=0.75, adj=c(0,0))