Sarah, David, thank you very much for your help! It all works now: ### My criterion for all counties: allcounties<-data.frame(county=map('county', plot=FALSE)$names) allcounties$group<-c(rep(1:6,513),rep(1,4))[order(c(rep(1:6,513),rep(1,4)))] ### My colors: classcolors <- rainbow(6) ### For gray border color: oldpar <- par(fg='gray') # change the default fg (foreground color) to white ### My US map: map('county',fill=TRUE,col=classcolors[allcounties$group],lty=3,bg = "transparent") ### For state borders: map('state', lwd=1, add=TRUE)
Dimitri On Fri, Jan 13, 2012 at 3:24 PM, David L Carlson <dcarl...@tamu.edu> wrote: > You can set the fg graphics parameter, for example > > oldpar <- par(fg='white') # change the default fg (foreground color) to > white > map('county', 'iowa', fill=TRUE, col='light gray') > oldpar # reset fg to the default - black > map('state', 'iowa', lwd=3, add=TRUE) > > Assuming you want the state outline in black with the county boundaries in > white. Otherwise just eliminate the last map command. > > ---------------------------------------------- > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > > > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Dimitri Liakhovitski > Sent: Friday, January 13, 2012 2:14 PM > To: Sarah Goslee > Cc: r-help > Subject: Re: [R] Coloring counties on a full US map based on a certain > criterion > >> >> But the help does say that additional arguments are passed to lines(), >> so you can use lty=0. >> >> That can leave white bits between counties if the areas don't line up >> precisely, so I think it looks better with the lines in black. > > I agree, indeed it leaves white bits. Of course, I could try to change > the type of the lines using lty... > Sorry for one more question: can one change the color of these lines > (borders between counties) from black? > Thank you! > D. > > >> >> Sarah >> >>> Thank you! >>> Dimitri >>> >>> ### My criterion for all counties.: >>> allcounties<-data.frame(county=map('county', plot=FALSE)$names) >>> > allcounties$group<-c(rep(1:6,513),rep(1,4))[order(c(rep(1:6,513),rep(1,4)))] >>> ### My colors: >>> classcolors <- rainbow(6) >>> map('county',fill=TRUE,col=classcolors[allcounties$group]) >>> map('state', lwd=2, add=TRUE) >>> >>> >>> >>>> Sure. Just start with >>>> map('county') >>>> instead. >>>> I like to add something like: >>>> map('state', lwd=3, add=TRUE) >>> >>> I am trying: >>> ### My criterion for all counties in the US: >>> allcounties<-data.frame(county=map('county', plot=FALSE)$names) >>> allcounties$group<-sample(1:5,3082,replace=TRUE) >>> ### My colors: >>> classcolors <- rainbow(5) >>> ### Trying to build the map - not working: >>> > map(database='usa',regions='county',fill=TRUE,col=classcolors[allcounties$gr > oup]) >>> >>> >>> >>>> You'll need to instead coordinate with the names of the entire US: >>>>> length(map('county', plot=FALSE)$names) >>>> [1] 3082 >>>> >>>> Sarah >>>> >> -- >> Sarah Goslee >> http://www.functionaldiversity.org > > > > -- > Dimitri Liakhovitski > marketfusionanalytics.com > > ______________________________________________ > R-help@r-project.org 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. > -- Dimitri Liakhovitski marketfusionanalytics.com ______________________________________________ R-help@r-project.org 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.