R 绘制国家边界不正确

R 绘制国家边界不正确,r,maps,gis,R,Maps,Gis,我打算根据属性值绘制一幅5种颜色的县级地图。我做到了,没有任何问题。现在,我想加上国家边界,结果不太好。边界线太直,各州的界限没有画好。它们不符合各州的实际限制 以下是我正在使用的代码: # Pick the colors for the categorical values colors = c("#CC0000", "#FF9999", "#E0E0E0", "#99FF99", "#00CC00") #Creates a new variable with the categories.

我打算根据属性值绘制一幅5种颜色的县级地图。我做到了,没有任何问题。现在,我想加上国家边界,结果不太好。边界线太直,各州的界限没有画好。它们不符合各州的实际限制

以下是我正在使用的代码:

# Pick the colors for the categorical values
colors = c("#CC0000", "#FF9999", "#E0E0E0", "#99FF99", "#00CC00")

#Creates a new variable with the categories.
data$colorBuckets <- as.numeric(cut(data$Slope, c(-0.30, -0.20, -0.10, 0.10, 
                                                0.20, 0.30)))
# Put a 3 (equivalent to slope 0) when there is NA's
data$colorBuckets[is.na(data$colorBuckets)] <- 3

# Matches the values of FIPS with the color categories
colorsmatched <- data$colorBuckets

library(mapproj)
# Map colored counties according the categories
map("county", col = colors[colorsmatched], fill = TRUE, resolution = 0, 
lty = 0, projection = "polyconic")

# Add border around each county
map("county", col = "gray", fill = FALSE, add = TRUE, lty = 1, lwd = 0.2,
projection = "polyconic")

# Add border to each state (THIS IS THE PROBLEMATIC STEP)
map("state", col = "black", fill = FALSE, add = TRUE, lty = 1, lwd = 0.4, 
       projection = "polyconic")

你知道为什么会发生这种情况吗?

你还没有提供答案。你没有在数据中包含任何数据。好的,我们无法运行代码,也看不到你的绘图是什么样子。你说的最终结果不好到底是什么意思?我试着用随机颜色和1.2的lwd绘制你的地图,你用了0.2,我得到了以下结果:在我看来,边界线似乎是合法的,看起来确实不错。嗨,非常感谢你的回答。我还不知道为什么我的地图上的州界是直线的。这是我最后得到的地图的链接:如果你想重现我正在做的事情,数据在这里: