World Map - Circle Charts, Circle Size Related to

I would like to be able to create a world map with circles on a graph related to No of Documents.

I tried to do this using mapBubbles, but when plotting something went wrong.

The data file that I have is as follows:

ISO3V10 Country No of Documents Lat Lon ARG Argentina 41 -64 -34 AUS Australia 224 133 -27 CAN Canada 426 -95 60 IRL Ireland 68 -8 53 ITA Italy 583 12.8333 42.8333 NLD Netherlands 327 5.75 52.5 NZL New Zealand 26 174 -41 ESP Spain 325 -4 40 GBR United Kingdom 2849 -2 54 USA United States 3162 -97 38 

The code I wrote below:

 # Thanks to Andrie for the reproducible code and Paolo for the suggested edit zz <-"ISO3V10 Country No.of.Documents Lat Lon ARG Argentina 41 -64 -34 AUS Australia 224 133 -27 CAN Canada 426 -95 60 IRL Ireland 68 -8 53 ITA Italy 583 12.8333 42.8333 NLD Netherlands 327 5.75 52.5 NZL 'New Zealand' 26 174 -41 ESP Spain 325 -4 40 GBR 'United Kingdom' 2849 -2 54 USA 'United States' 3162 -97 38 " dF2 <- read.table(textConnection(zz), header = TRUE) # dF2 <- read.delim(file="C:\\Users\\js207963\\Documents\\noofpublications_AllUpdated.txt", header = TRUE, sep = "\t") dF2[] par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i") mapBubbles(dF2=getMap(), nameZSize="No.of.Documents", nameZColour="Country",oceanCol="lightblue", landCol="wheat", addLegend=FALSE 

So the question is, can you help me fix the code to print the data correctly?

Cheers, Jess

+4
source share
2 answers

You can build this in ggplot using:

enter image description here

Recover your data:

 dat <- read.table(text=" ISO3V10 Country 'No of Documents' Lat Lon ARG Argentina 41 -64 -34 AUS Australia 224 133 -27 CAN Canada 426 -95 60 IRL Ireland 68 -8 53 ITA Italy 583 12.8333 42.8333 NLD Netherlands 327 5.75 52.5 NZL 'New Zealand' 26 174 -41 ESP Spain 325 -4 40 GBR 'United Kingdom' 2849 -2 54 USA 'United States' 3162 -97 38 ", header=TRUE) 

Download packages and graphics:

 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=dat, aes(x=Lat, y=Lon, map_id=Country, size=`No.of.Documents`), col="red") 
+6
source

You need to pass a little more information to the mapBubbles function, since your data frame is not a SpatialPolygonsDataFrame spatial template. The following should work (you Lat and Lon may be mistakenly marked):

  mapBubbles(dF=dF2, nameZSize="No.of.Documents", nameZColour="Country",oceanCol="lightblue", landCol="wheat", addLegend=FALSE, nameX = "Lat", nameY = "Lon") 

Above, nameX and nameY are passed to the function to indicate where to display the bubbles. Also, pass the dF2 data frame to the dF2 argument instead of calling getMap() .

EDIT:

I also like the way Andri answers using ggplot2 (by the way, space is better to use than in the graph below), but since you added other questions specifically using rworldmap , I found it appropriate to stick with this package.

World map with bubbles

+1
source

Source: https://habr.com/ru/post/1414325/


All Articles