# Join data and world datasets library(ggplot2) library(maps) library(tidyverse) library(sf) library(plotly) library(ggmap) library(dplyr) library(PBSmapping) # to clip polygons require(ggthemes) # Import worldmap data library(rworldmap) worldmap = map_data('world') worldmap2 <- worldmap[order(worldmap$group, worldmap$order),] # Import dataset (number of articles per country) library(readxl) data <- read_excel("/Users/lwhatford/Desktop/Data.xlsx") # Join data and world datasets mapdata <- left_join(worldmap, data, by="region", copy = TRUE) mapdata$numart <- as.integer(mapdata$numart) mapdata <- mapdata %>% arrange(numart) p<-ggplot() + geom_polygon(data = mapdata, aes(x=long, y=lat, group=group, fill = as.factor(range)),colour="grey50")+theme(panel.grid.major = element_blank(), panel.background = element_rect(fill = "white"))+theme_void() p2<-p+scale_fill_manual(values = c("#1a9850","#66bd63","#a6d96a","#d9ef8b","#ffffbf","#fee08b","#fdae61","#f46d43","#d73027"), name="Number of articles per country",limits=c("0-10", "10-50", "50-100", "100-200", "200-300", "300-400", "400-500", "500-600", "600 +")) p2 p3<-p2+theme(legend.position="bottom") p3 png("fig2.png",type="cairo",units="in",width=10,height=5,res=300) plot(p3) dev.off()