Dear helpeRs,

I'm working with the map-package and came upon a problem which I  
couldn't solve. I hope onee of you can. If not, this can be seen as a  
suggestion for new versions of the package.

I'm trying to create a map of some European countries, filled with  
colors corresponding to some values. Let's say I have the following  
countries and I assign the following colors (fictional):

country2001 <- c("Austria", "Belgium", "Switzerland",  
"Czechoslovakia", "Germany", "Denmark", "Spain", "Finland", "France",  
"UK", "Greece", "Hungary", "Ireland", "Israel", "Italy",  
"Luxembourg", "Netherlands", "Norway", "Poland", "Portugal",  
"Sweden", "Slovenia")
color2001 <- c("green", "yellow","red","red", "red", "red", "red",  
"red", "green", "red", "red", "red", "red", "red", "red", "red",  
"red", "blue", "red", "red", "red", "orange")

I then let the colors and the values correspond using 'match.map',  
like this:

match <- match.map("world",country2001)
color <- color2001[match]

And finally I plot the map. It works perfectly fine.

map(database="world", fill=TRUE, col=color)


But as I mentioned, I want to create a map of Europe. So, I use xlim  
and ylim to let some parts of the world fall of the map. The syntax  
becomes like this:

map(database="world", fill=TRUE, col=color, xlim=c(-25,70),ylim=c 
(35,71))

Now, a problem arises. The regions on the map are colored by the  
vector 'color'. It needs therefore to correspond to the order in  
which the polygons are drawn. Since some of the full world-map isn't  
drawn this time, the color-vector doesn't correspond anymore. This  
results in the coloring of the wrong countries.

Does anybody know of a way to solve this?

Thanks very much in advance,

Rense Nieuwenhuis
        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to