首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用R中的identify函数

使用R中的identify函数
EN

Stack Overflow用户
提问于 2014-04-23 11:07:03
回答 2查看 24K关注 0票数 4

在散点图中,我想使用identify函数来标记右侧的顶点。

我这样做了:

代码语言:javascript
复制
identify(x, y, labels=name, plot=TRUE)

*我有一个命名的向量。

然后,当它运行时,我指向正确的点。然后在停止它之后,它向我显示点的标签。

每次都必须单击要标记的点吗?我可以保存它吗?

EN

回答 2

Stack Overflow用户

发布于 2014-04-23 11:16:22

代码语言:javascript
复制
# 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.

关于保存它:我不能使用

代码语言:javascript
复制
pdf() 
# plotting code
dev.off()

然而,在Rstudio中,可以“复制-粘贴”它。如果你只需要一个图,我想这是可行的。

票数 7
EN

Stack Overflow用户

发布于 2015-02-12 06:43:18

您可以使用identify函数的返回值来重现标签:

代码语言:javascript
复制
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

代码语言:javascript
复制
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()
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23234046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档