简体   繁体   English

R,ggplot2和点为六边形单元格的世界地图

[英]R, ggplot2 and a world map with points un hexagone cell

I have a data frame like 我有一个数据框

 X                date         lon      lat 
1 1 2014-01-08 23:50:13 -116.576504 53.93327
2 2 2014-01-08 23:35:50          NA       NA
3 3 2014-01-08 23:06:33          NA       NA
4 4 2014-01-08 23:06:07  -76.670200 39.38100
5 5 2014-01-08 22:44:37  -77.436048 37.54072
6 6 2014-01-08 22:35:56    7.189811 43.67342

and I would like to map it on a world shape file, but if my points could be in hexagon... with ggplot2 .. it will be great! 我想将其映射到一个世界形状文件中,但是如果我的点可以是六边形...使用ggplot2 ..那就太好了! I'm not abble to use geom_hex ... it doesn't make what I whant ... Something like that but with a world map below. 我不是很想使用geom_hex……这并没有使我想要…… 像那样,但是下面有一张世界地图。 A complexe way is on the slide 22 of this presentation , I have tried 我尝试了一种复杂的方式在此演示文稿的幻灯片22上

wp<-ggplot()+
  geom_polygon(data=word.df,aes(long,lat,group=group))+
  geom_path(color="white")+
  geom_hex(data=cleanTwittes,aes(lon,lat))+
  coord_equal()

but I'have this error : 'Erreur dans if (nrow(layer_data) == 0) return() : ' 但是我有这个错误:'Erreur dans if(nrow(layer_data)== 0)return():'

thank's 谢谢

I have find something :-) 我发现了一些东西:-)

wp<-ggplot()+
   geom_polygon(data=word.df,aes(long,lat,group=group))+
   geom_hex(data=cleanTwittes,aes(lon,lat),bins = 55,alpha=8/10)+
   theme_bw()+
   labs(title = paste(nbTwittes,"twittes entre",minT,"et",maxT, "sur 'terroir'"))
   coord_equal()

It make a map not so bad 它使地图还不错 在此处输入图片说明

But if you have some sugestion ... 但是如果您有一些建议的话...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM