0

I am intending to plot a county level map with 5 colors depending on a value of an attribute. I did that with no problems. Now, I want to add the state borders and the end result is not good. The border lines are too straight and the limits of the states are not well plotted. They do not follow the actual limits of the states.

Here is the code I am using:

# 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")

Any idea why this may be happening?

Giuseppe Petri
  • 604
  • 4
  • 14
  • 2
    You haven't provided a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You didn't include any data in `data.ok` we can't run the code and we can't see what your plot looks like. – MrFlick May 21 '15 at 20:40
  • 2
    What exactely do you mean by "the end result is not good"? I tried plotting your map with random colors and a lwd of 1.2 (you used 0.2) and I get the following result: http://i.imgur.com/mue3xBO.png The border lines seem legit and do look nice in my opinion. – maRtin May 21 '15 at 21:38
  • Hi, Thanks a lot for your responses. I could not yet find out why the state borders of my map are straight lined. Here is the link to the map I ended up with: http://imgur.com/UqcpVBW If you want to reproduce what I am doing, the data is here: http://www.filedropper.com/data_4 – Giuseppe Petri May 24 '15 at 14:29

0 Answers0