将文本放在有空白处的r图中
我需要在R中的几个不同图中添加一些文本,此文本的最佳位置将取决于每个特定绘图没有(t多)点的位置,以最大程度地减少文本/点重叠。示例:
par(mfrow = c(1, 2))
plot(cars)
text(5, 100, "some text here.", adj = 0, cex = 0.7)
plot(iris[ , 3:4])
text(3, 0.5, "some text here.", adj = 0, cex = 0.7)
有没有办法(最好使用base R)自动获得每个文本的良好位置情节,而不是我必须先查看每个图,然后设置5、100
和3、0.5
手动?
I need to add some text to several different plots in R. The best location for this text will depend on where each particular plot has no(t many) points, to minimize text/point overlap. Example:
par(mfrow = c(1, 2))
plot(cars)
text(5, 100, "some text here.", adj = 0, cex = 0.7)
plot(iris[ , 3:4])
text(3, 0.5, "some text here.", adj = 0, cex = 0.7)
Is there a way (preferably with base R) to automatically get a good placement for the text in each plot, instead of me having to first look at each plot and then set 5, 100
and 3, 0.5
manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道任何内置功能,但是编写一个功能来计算最空虚的象限并不难。 @jay.sf的评论提到了“概念”等。这些关键字适用于
Legend
,但似乎在文本
中不起作用,因此我将使用gudence
代码>写文本。首先,现在的功能您只需计算传奇的最佳位置即可。
I do not know of any built-in function, but it is not hard to write a function to compute the emptiest quadrant. The comment by @jay.sf mentioned "topright" etc. Those keywords work for
legend
but do not seem to work intext
so I will uselegend
to write the text. First, the functionNow you can just compute the best location for the legend.