r - Moving position of country names in Rworldmap -


is there way move position of names of countries on maps generated rworldmap? instance, in example below move names of central american countries easier read.

if not, i'd welcome suggestions on alternative ways label map. thanks.

library(rworldmap)   df <- null   df$country <- c("el salvador","mexico","panama", "nicaragua", "costa rica",       "cuba", "honduras", "guatemala", "venezuela")   df$code<-c("slv", "mex", "pan", "nic", "cri", "cub", "hon", "gtm", "ven")   df$number<-c(100, 500, 200, 150, 300, 390, 140, 330, 60)   df<-as.data.frame(df)   spdf <- joincountrydata2map( df, joincode = "iso3", namejoincolumn = "code")  mapcountrydata(spdf, namecolumntoplot="number")  spdfmycountries <- spdf[spdf$name %in% df$country,]  mapcountrydata(spdfmycountries, namecolumntoplot="number", catmethod="fixedwidth", colourpalette="heat", bordercol="black",  maptitle = ("made number")) text(spdfmycountries, labels="name") 

you can create offset column in spatial or standard dataframe , apply argument position of text label. (i had same issue comment above, converted spdf regular df):

mapcountrydata(spdfmycountries, namecolumntoplot="number", catmethod="fixedwidth", colourpalette="heat", bordercol="black",  maptitle = ("made number")) df2=as.data.frame(spdfmycountries) df2$latoffset=4 #4 degree offset df2$lonoffset=4 text(df2$lon+df2$latoffset, df2$lat+df2$lonoffset, labels=df2$country) 

given arrangement of countries mapped, don't know if find solution unclutter overlapping text boxes automatically not stray names far of smaller countries, thinking may want tweak individual offset columns liking...

if want find way declutter labels automatically, there seems few resources out there: https://stats.stackexchange.com/questions/16057/how-do-i-avoid-overlapping-labels-in-an-r-plot


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -