ggplot2 - Incorrect Long/Lat Plotting with ggplot -


dat <- read.table(text=" 'country_of_asylum' 'iso_3' 'refugees_1000_inhabitants' lat long     lebanon lbn   208.91 33.8333  35.8333     jordan  jor    89.55 31.0000  36.0000     nauru   nru   50.60 -0.5333 166.9167     chad   tcd    30.97 15.0000  19.0000     turkey   tur  23.72 39.0000  35.0000     'south sudan'   ssd 22.32  4.8500  31.6000     mauritania   mrt  19.36 20.0000 -12.0000     djibouti   dji    16.88 11.5000  43.0000 sweden   swe  14.66 62.0000  15.0000 malta   mlt  14.58 35.9000  14.4000", header=true)  data.frame(top_ten_pcapita) library(ggplot2) library(maps) mdat <- map_data('world') str(mdat) ggplot() +    geom_polygon(dat=mdat, aes(long, lat, group=group), fill="grey50") +   geom_point(data=top_ten_pcapita,               aes(x=lat, y=long, map_id=iso_3, size=`refugees_1000_inhabitants`), col="red")        

i tried make map on ggplot, longitudes , latitudes off. i'm not entirely sure what's going on. example, why lat. going on 100 on map?

enter image description here

you mixed longitude , latitude. if added labels points you'd see none of countries plotted @ correct place.

so make sure x = longitude , y = latitude , it'll work:

ggplot() +    geom_polygon(dat = mdat, aes(long, lat, group = group), fill = "grey50") +   geom_point(data = top_ten_pcapita,               aes(x = long, y = lat, size = refugees_1000_inhabitants), col = "red") 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -