
library(lattice)

myPrdctrA <- c(slctPrdctr[1:nprdFirst],"ALLP_INT")
myPrdctr <- PRDCTRS 
dirfreq <- paste0(workingDir, "/epsfreq/")

prdtxt0 <- paste0("_L",iLead,"_PRCP_Multinom_")
prdtxt1  <- paste0(FTYPEF,"_predictor_frequency.csv")
numcols <- 24  # this is for color levels
for (imodel in 1:length(modelFileNames)) {
  mytab <- matrix(NA,nrow=length(myPrdctr), ncol=length(myPrdctrA))
  dimnames(mytab) <- list(myPrdctr,myPrdctrA)
  for (irun in 1: length(myPrdctr)) {
     file1 <- paste0(workingDir, "/analdat/",modelFileNames[imodel],prdtxt0, 
		          myPrdctr[irun],prdtxt1)
    print(file1)
     x <- read.csv(file1, skip=0)
     dimnames(x)[[1]] <- x$predictor
     mytab[myPrdctr[irun],rownames(x)] <- x[rownames(x),"count"]
   }
     diag(mytab) <- NA
#     mytab <- mytab/max(mytab, na.rm=T)

     tmin = min(mytab, na.rm=T)
     tmax = max(mytab, na.rm=T)
    atLabels  = c(-Inf, seq(tmin, tmax, length = numcols - 3), Inf)

   frqname <- paste0(dirfreq,modelFileNames[imodel],"_L",iLead,FTYPEF,"_pFrequency")

   png(filename=paste0(frqname,".png"))

    pp <-   levelplot(mytab, 
            col.regions = terrain.colors(numcols, rev = TRUE),
            xlab = " Models ", ylab = "Predictors",
            main = paste0("Domain-wide number of predictors used (",SEASON,")"),
            at = atLabels,
            scales = list(x = list(rot = 45),y = list(rot = 0))
        )
   print(pp)
  dev.off()
}

