I'm having issues when trying to do a filled State plot using the maps()
package.  It seems that the color values aren't being plotted correctly,
and I'm not sure why...

I've started debugging it, but I'm stuck.  I've attached the code that I've
got so far.  The for loop plots states 1:i.  What I'm noticing is that the
colors are correct until after Michigan gets plotted (i=24).  Then, the
colors change each time the for loop is executed.  I'm guessing it has
something to do with Michigan having multiple regions, but I have no idea
what to do from here.  Help! (and thanks for taking the time to read
this/help me out)

state = c("Alabama","Alaska","Arizona","Arkansas",
"California","Colorado","Connecticut","Delaware",
"District Of Columbia","Florida","Georgia",
"Hawaii","Idaho","Illinois","Indiana",
"Iowa","Kansas","Kentucky","Louisiana",
"Maine","Maryland","Massachusetts",
"Michigan","Minnesota","Mississippi","Missouri",
"Montana","Nebraska","Nevada","New Hampshire",
"New Jersey","New Mexico","New York","North Carolina",
"North Dakota","Ohio","Oklahoma","Oregon",
"Pennsylvania","Rhode Island","South Carolina","South Dakota",
"Tennessee","Texas","Utah","Vermont",
"Virginia","Washington","West Virginia","Wisconsin","Wyoming")

dState = data.frame( col=rbinom(51,size=2,prob=.6)+1, state=state )

for( i in 1:51 ){
  dTemp = dState[1:i,]
  map("state", regions = dTemp$state,
#      boundary = TRUE,
#      lty = 1, lwd =1,
      col= dTemp$col,
      fill=T)
  readline( paste( "Current i is", i ) )
}

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to