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

2013-02-04 Thread Ryan Flaherty
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=enhl=enkey=0Aj
zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=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(#7F, blue, #007FFF, cyan,
 #7FFF7F, yellow, #FF7F00, red, #7F))

##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
rflahe...@coas.oregonstate.edu

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


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

2013-02-04 Thread Richard M. Heiberger
This will get you started

library(lattice)
library(latticeExtra)

D1 - data.frame(y=1:3, x=4:6)
D2 - data.frame(y=7:10, x=11:14)

T1 - xyplot(y ~ x, data=D1,
 key=list(space=right, text=list(LETTERS[1:3],
col=c(red,green,blue

T2 - xyplot(y ~ x, data=D2,
 key=list(space=right, text=list(LETTERS[4:7],
col=c(orange,purple,brown,pink

c(T1, T2, layout=c(1,2), merge.legends=TRUE)


Rich


On Mon, Feb 4, 2013 at 2:37 PM, Ryan Flaherty ryan1.flahe...@gmail.comwrote:

 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=enhl=enkey=0Aj
 zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=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(#7F, blue, #007FFF, cyan,
  #7FFF7F, yellow, #FF7F00, red, #7F))

 ##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
 rflahe...@coas.oregonstate.edu

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


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


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

2013-02-04 Thread Richard M. Heiberger
On further thought, this might be better as it keeps the keys distinct

library(lattice)
library(latticeExtra)

D1 - data.frame(y=1:3, x=4:6)
D2 - data.frame(y=7:10, x=11:14)

T1 - xyplot(y ~ x, data=D1,
 key=list(space=right, text=list(LETTERS[1:3],
col=c(red,green,blue

T2 - xyplot(y ~ x, data=D2,
 key=list(space=right, text=list(LETTERS[4:7],
col=c(orange,purple,brown,pink

c(T1, T2, layout=c(1,2), merge.legends=TRUE)


print(update(T1, xlim=c(3,15)), split=c(1,1,1,2), more=TRUE)
print(update(T2, xlim=c(3,15)), split=c(1,2,1,2), more=FALSE)



On Mon, Feb 4, 2013 at 3:06 PM, Richard M. Heiberger r...@temple.edu wrote:

 This will get you started

 library(lattice)
 library(latticeExtra)

 D1 - data.frame(y=1:3, x=4:6)
 D2 - data.frame(y=7:10, x=11:14)

 T1 - xyplot(y ~ x, data=D1,
  key=list(space=right, text=list(LETTERS[1:3],
 col=c(red,green,blue

 T2 - xyplot(y ~ x, data=D2,
  key=list(space=right, text=list(LETTERS[4:7],
 col=c(orange,purple,brown,pink

 c(T1, T2, layout=c(1,2), merge.legends=TRUE)


 Rich


 On Mon, Feb 4, 2013 at 2:37 PM, Ryan Flaherty ryan1.flahe...@gmail.comwrote:

 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=enhl=enkey=0Aj
 zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=csvhttps://docs.google.com/spreadsheet/pub?hl=enhl=enkey=0AjzYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=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(#7F, blue, #007FFF, cyan,
  #7FFF7F, yellow, #FF7F00, red, #7F))

 ##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
 rflahe...@coas.oregonstate.edu

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




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