2017-04-12 85 views
0

从传说中的图片corresonding号我使用的代码ggplot(product_info,aes(x=lat,y=lon,colour=factor(location)))+geom_point() ,图片类似这样的enter image description here我怎么能显示GGPLOT2

我想从图例显示在这些丰富多彩的点在一起的图片数量。

回答

2

您可以使用geom_text()显示相应因子的文本。下面是与diamonds数据集的例子:

ggplot(diamonds, aes(x=price, y=carat, colour=factor(cut), label=factor(cut))) + 
    geom_point() + 
    geom_text() 

enter image description here

或者,你可以考虑ggplotly这将提供查看数据

library(plotly) 
p <- ggplot(diamonds, aes(x=price, y=carat, colour=factor(cut))) 
    + geom_point() 
ggplotly(p) 

enter image description here

+0

更简单的方法哦,感谢您的回答 –