[R] Mapping of groups of countries

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Sun Jan 2 23:00:06 CET 2022


Hi George,
Same to you. I fooled around with the plot a bit after I sent the email.

Jim

On Mon, Jan 3, 2022 at 8:36 AM george brida <george.brida using gmail.com> wrote:
>
> Thanks a lot Jim. I really appreciate your help. Happy new year 2022.
> George
>
> On Wed, Dec 29, 2021 at 10:10 PM Jim Lemon <drjimlemon using gmail.com> wrote:
>>
>> 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 using 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 using 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.


More information about the R-help mailing list