私はこのようなデータセットを持っています
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 色しか使用されていないため、多くの国が赤色になっています。使用する色をさらに指定するにはどうすればよいですか? 次のようなプロットを取得したいと思います。