我打算根据属性的值绘制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")
知道为什么会这样吗?