title: treemap [R]: how to fix the color assignment
body: <p>I'm making series of treemaps, and want "A" in each plot always has the same color, and "B" in each plot always has the same color, etc.</p>
  
  <p>The vSize of "A" may even be 0 in some plots - I padded rows of 0 in this case, but this didn't fix the issue. Can somebody help please... Thanks!</p>
  
  <pre><code>library(dplyr)
  library(treemap)
  
  #set directory
  setwd('')
  
  nRow = 200
  
  dt1 = data.frame(month = sample(month.abb, nRow, replace=T),
                   town = sample(LETTERS, nRow, replace=T),
                   count = sample(1:100, nRow, replace=T))
  
  # make some towns bigger so that it's easier to see
  dt1[dt1$town=='A', 'count'] = dt1[dt1$town=='A', 'count'] + 500
  dt1[dt1$town=='B', 'count'] = dt1[dt1$town=='B', 'count'] + 400
  dt1[dt1$town=='C', 'count'] = dt1[dt1$town=='C', 'count'] + 300
  dt1[dt1$town=='D', 'count'] = dt1[dt1$town=='D', 'count'] + 200
  dt1[dt1$town=='E', 'count'] = dt1[dt1$town=='E', 'count'] + 100
  
  empty = data.frame(name = LETTERS,
                     count = rep(0, length(LETTERS)))
  
  for (i in 1:length(month.abb)){
  
          byTownEachMonth = dt1 %&gt;%
                  filter( month == month.abb[i] ) %&gt;%
                  group_by(town) %&gt;%
                  summarise( count = sum(count) )
  
          # pad rows/towns of 0 count
          byTownEachMonth = rbind(byTownEachMonth, 
                                  empty[ ! empty$town %in% byTownEachMonth$town, ] )
  
          byTownEachMonth = byTownEachMonth[order(byTownEachMonth$town), ]
  
          byTownEachMonth$label = paste0(byTownEachMonth$town, ' ', 
                                         byTownEachMonth$count)
  
          png(width=800, height=600, file=paste0('tm_', month.abb[i], '.png'))
  
                  treemap(byTownEachMonth, 
                          index = 'label',
                          vSize ='count',
                          vColor = 'town',
                          type = 'categorical',
                          inflate.labels = F)          
          dev.off()              
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lafEk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lafEk.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/5t6Cg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5t6Cg.png" alt="enter image description here"></a></p>