识别 R 图中的值

问题描述

我一直在尝试识别 R ggplot2 中的极值。

有什么方法可以绘制一个图,除了表示值的点(或代替点)之外,它还显示索引?或者任何其他可以让您快速识别它的东西?

我发现最接近的是 identify() 函数,但它对我来说效果不佳。

有什么建议吗?

我将给出一个基本的 ggplot 图:

df = data.frame(x = runif(10,1),y = runif(10,1))
ggplot(df,aes(x,y)) +
  geom_point(col="red") + theme_bw()

解决方法

更新:

我一直在尝试新事物。我终于得到了我想要的。

df = data.frame(x = runif(10,1),y = runif(10,1))
ggplot(df,aes(x,y,label = rownames(df))) +
  geom_point() + geom_text() + theme_bw()

Output

现在我可以轻松识别我想要的值。希望它可以帮助其他不熟悉 ggplot 的人。

如果有人知道如何改进它,请随时这样做。

,

我建议安装 plotly 软件包然后运行:

plotly::ggplotly(.Last.value)

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...