gpt4 book ai didi

r - 在 R 中使用带有文本的 pos 向量

转载 作者:行者123 更新时间:2023-12-03 02:46:25 26 4
gpt4 key购买 nike

我正在尝试使用 text对我的情节说几句话。我想在向量中使用 pos 参数,这样我就可以指定将哪些单词(例如)放置在指定坐标上方。但我不知道要在向量中放入什么,以便将某些文本元素保留在指定的坐标处!该文档允许输入 1、2、3 或 4,每个条目都会将文本移离坐标。为了不进行任何更改,我可以在 pos.vector 中使用什么值?

谢谢!

编辑:

这是我想要做的一个例子:首先,我尝试:

radius <- sqrt(z/pi)    
symbols(x,y, circles = radius)
text(z,y,labels=urls)

但这会在标签中产生一些重叠,因此我尝试包含一个 pos 向量:

pos.vector <- rep(3, length(urls)) #have to use 1, 2, 3, or 4 here
pos.vector[urls %in% c("victoriassecret")] <- 4
radius <- sqrt(z/pi)
symbols(x,y, circles = z)
text(z,y,labels=urls,pos=pos.vector)

但是这种方法使我无法将其余标签保持居中,因为 pos 向量仅接受 1、2、3 或 4 作为输入。咕噜。

最佳答案

通过 Map 多次运行 text 即可到达,例如:

pts <- seq(0,1,length.out=4)
plot(pts,pts,pch=19)
Map(text, x=pts, y=pts, labels=letters[1:4], pos=list(4,4,NULL,1))

enter image description here

关于r - 在 R 中使用带有文本的 pos 向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27368621/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com