我有这样的数据集
Country GDP
Afghanistan 20315
Albania 12800
我的代码如下
library(rworldmap)
library(RColorBrewer)
library(ggplot2)
countries = read.csv("countries.csv", na.strings = " NA")
countries$GDP = as.numeric(as.character(countries$GDP))
sPDF = joinCountryData2Map(countries, joinCode = "NAME", nameJoinColumn = "Country", verbose = TRUE)
mapParams = mapCountryData(sPDF, nameColumnToPlot = "GDP", missingCountryCol = "dark grey", addLegend = FALSE, oceanCol = "lightsteelblue2")
do.call(addMapLegend, c(mapParams, legendWidth = 0.5, legendMar = 2))
这就是我得到的情节
如您所见,很多国家都被涂成红色,因为图例中只使用了 7 种颜色。如何指定要使用的更多颜色?我想得到这样的情节: