我正在并排绘制 5 个栅格。该图表示线性回归模型,因此该图应表示 r1 ~ r2 + r3 + r4 + r5
。我正在使用par()
排列 5 个栅格,现在想添加文本标志 ~,+,+,+
在白色间隙的顶部。
多图示例:
par(mfrow = c(1,5))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
最佳答案
您可以使用mtext
在绘图的边缘写入一些内容:
par(mfrow = c(1,5))
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
mtext(side = 4, line = 1, "~", cex = 5, font = 2, las = 2)
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
mtext(side = 4, line = 4, "+", cex = 5, font = 2)
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
mtext(side = 4, line = 4, "+", cex = 5, font = 2)
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
mtext(side = 4, line = 4, "+", cex = 5, font = 2)
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
请注意,side = 4
指的是图的右侧。 las = 2
将文本旋转 90 度。 font=2
指的是粗体字体。
如果您希望绘图之间的文本更大,您可以选择 cex = 4
或什至更大。
关于r - 在多个绘图之间添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58732125/