[R] Coloring counties on a full US map based on a certain criterion

Sarah Goslee sarah.goslee at gmail.com
Fri Jan 13 21:48:21 CET 2012


Hi Ray,

I'm glad to see you here. I was going to write this up a bit more
clearly and email it to you, but now I don't have to bother. :)

> Coincidentally, I became aware of this just recently.  When the maps package
> was created (way back in the "'new' S" era), polygon() didn't add borders,
> and that is why ?map states that fill does not add borders.  A workaround is
> to change the map() option border= to myborder= (it is then used twice in
> map()).

I though it was probably a legacy code issue.

> In fact I believe there is another workaround if you don't want to modify
> the code; use the option resolution=0 in the map() call. I.e. try (in
> Sarah's original Iowa example):
>
> map('county', 'iowa', fill= TRUE, col = classcolors[countycol],
> resolution=0, lty=0)
>
> This ensures that the polygon boundaries match up.

Ah! That works nicely, and wasn't clear to me from the help that it
would do so.

Thanks!

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list