作者:手浪用户2602928705 | 来源:互联网 | 2023-10-12 17:29
I have dataset like this
我有这样的数据集
Country GDP
Afghanistan 20315
Albania 12800
My code is as follows
我的代码如下
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))
And this is the plot I'm getting
这就是我得到的情节
As you can see, a lot countries are colored red because only 7 colors are used in the legend. How can I specify more colors to be used? I'd like to get a plot like this:
如您所见,很多国家都是红色的,因为图例中只使用了7种颜色。如何指定更多颜色?我想得到一个这样的情节:
1 个解决方案