在散点图中,我想使用identify函数来标记右侧的顶点。
我这样做了:
identify(x, y, labels=name, plot=TRUE)*我有一个命名的向量。
然后,当它运行时,我指向正确的点。然后在停止它之后,它向我显示点的标签。
每次都必须单击要标记的点吗?我可以保存它吗?
发布于 2014-04-23 11:16:22
# Here is an example
x = 1:10
y = x^2
name = letters[1:10]
plot(x, y)
identify(x, y, labels = name, plot=TRUE)
# Now you have to click on the points and select finish at the end
# The output will be the labels you have corresponding to the dots.关于保存它:我不能使用
pdf()
# plotting code
dev.off()然而,在Rstudio中,可以“复制-粘贴”它。如果你只需要一个图,我想这是可行的。
发布于 2015-02-12 06:43:18
您可以使用identify函数的返回值来重现标签:
labels <- rep(letters, length.out=nrow(cars))
p <- identify(cars$speed, cars$dist, labels, plot=T)
#now we can reproduce labelling
plot(cars)
text(cars$speed[p], cars$dist[p], labels[p], pos=3)要在使用identify后保存绘图,可以使用dev.copy
labels <- rep(letters, length.out=nrow(cars))
identify(cars$speed, cars$dist, labels, plot=T)
#select your points here
dev.copy(png, 'myplot.png', width=600, height=600)
dev.off()https://stackoverflow.com/questions/23234046
复制相似问题