2017-04-12 55 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

更簡單的方法哦,感謝您的回答 –