[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    Re: [R] Mapping of groups of countries
From:       Jim Lemon <drjimlemon () gmail ! com>
Date:       2021-12-29 21:10:24
Message-ID: CA+8X3fU-Xczjp6X7oRmdCPaZ8YrdQYUGkZ63o874Ji0c6b7HfA () mail ! gmail ! com
[Download RAW message or body]

Hi George,
This example is obviously a mess, but it shows the basic elements. The
labels may be placed manually using something like boxed.labels
(plotrix) with lines connecting the labels to the smaller countries.
If you want the labels within the countries you will have to use a big
graphics device.

library(maps)
map("world")
countries=c("China","Bangladesh","Egypt","Indonesia","South Korea","Nigeria",
 "Brazil","Pakistan","Philippines","Vietnam","South Africa",
 "India","Mexico","Turkey")
countrycol<-c(rep("red",6),rep("blue",4),"green",rep("orange",3))
for(i in 1:length(countries)) {
 mapinf<-map(region=countries[i],col=countrycol[i],add=TRUE)
 xpos<-sum(mapinf$range[1:2])/2
 ypos<-sum(mapinf$range[3:4])/2
 text(xpos,ypos,countries[i])
}


Jim

On Thu, Dec 30, 2021 at 7:34 AM george brida <george.brida@gmail.com> wrote:
>
> Dear R users,
>
> I would like to map with R the following countries (with their names on the
> map) as follows: the first group in red composed by China, Bangladesh,
> Eypt, Indonesia, South Korea, Nigeria. The second group in blue composed by
> Brazil, Pakistan, Philippines, Vietnam.
>
> The third group in green solely composed by South Africa.
>
> Finally, the fourth group in orange composed by India, Mexico and Turkey.
>
> I'd also like a legend that assigns the different colors to the various
> group.
> I tried several times with library maps but it seems that I failed to find
> the real setting of xlim and ylim. Can you please help me, I will be very
> grateful.
>
> Best regards
> George
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic