Reputation: 139
I want to draw a US map with some states have blue color and others have white color
Now, I have the list of names of state:
c=c("ILLINOIS", "KANSAS","LOUISIANA","MAINE","MICHIGAN","MINNESOTA","MISSISSIPPI" )
However, when I use:
map(database = "state",regions = c,col = "blue",fill=T)
This is not I want, I want to see other states with white color, what should I do?
Upvotes: 1
Views: 10343
Reputation: 1210
@rawr solution in comments worked. to create a full map with fill colors:
map(database = "state")
map(database = "state",regions = c,col = "blue",fill=T,add=TRUE)
Upvotes: 4
Reputation: 263342
At the moment you are asking R to only plot those states so you need to drop the region
-argument and figure out a way to match color choices with the names of the states:
require(maps)
namevec <- map(database = "state", col = "blue",fill=T, namesonly=TRUE)
> str(namevec)
chr [1:63] "alabama" "arizona" "arkansas" "california" ...
So try this:
map(database = "state",col = c("white", "blue")[1+(namevec %in% tolower(c) )],fill=T)
Upvotes: 4