[R] is it possible to create a trellis object with multiple colorkeys/z-scale axis?

Ryan Flaherty ryan1.flaherty at gmail.com
Mon Feb 4 20:37:02 CET 2013


Dear R users-

Do the lattice/latticeExtra packages support multiple tileplots with unique
colorkeys? I am trying to create a visualization of the encounter rate of
certain stocks of salmon across two years. The issue I am having is that
some stocks are encountered at much higher rates than others.the high
encounter rate for one stock washes out the patterns I'm hoping to visualize
across the other, less common, stocks. In the example below, the high
encounter rate of Central Valley Fall (CVF) in San Francisco (SF) during
June of 2011 makes it impossible to identify differences in encounter rate
of the other stocks. Is there a way to create the same plot but with a
unique colorkey for each panel? 

#Please first load packages RCurl and latticeExtra

#Import data
getdata<-getURL("https://docs.google.com/spreadsheet/pub?hl=en&hl=en&key=0Aj
zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUE&single=true&gid=0&output=csv",ssl.
verifypeer=FALSE)
test<-read.csv(textConnection(getdata),header=T)
test$year<-as.factor(test$year)
head(test)

##Custom color ramp
jet.colors <-
  colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
                     "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))

##create trellis of tileplots
betweenyear<-tileplot(index~month*-area|stock+year,test,col.regions=jet.colo
rs(256),
	scales=list(x=list(at=5:9, labels=c('May'
,'Jun','Jul','Aug','Sep'),cex=0.6), 
      y=list(at=(-1):-8,labels=c('T','N','C','B','KC','FB','SF','MO'))),
	main = list(label="Stock specific encounter rate by WCGSI: 2010
versus 2011",cex=0.75) ,
	xlab= "Month",
	ylab= "Management Area",
	border = "black",
	panel = function(...){
	panel.fill("black")
	panel.voronoi(...)
	})

##plot object
plot(betweenyear)

Thank you for your time and consideration.

Regards,

Ryan

Ryan Flaherty
Oregon State University
College of Oceanic and Atmospheric Science
Marine Resource Management
541-513-0293
rflaherty at coas.oregonstate.edu



More information about the R-help mailing list