[R] Multiple color schemes for barchart (lattice)

From: Sarah Hawley <sarah_at_canaryfoundation.org>
Date: Wed, 06 Jun 2007 12:44:11 -0700


Hello R-help.

I am trying to make a stacked barplot where the color of the sections of each bar depend on another variable.

> myData[1:11,]

   score   percent    marker     cellType Malignant
1      0 100.00000 ESR1 (ER) Bladder.M(5) TRUE
2      0  80.00000      PAX8 Bladder.M(5) TRUE
3      1  20.00000      PAX8 Bladder.M(5) TRUE
4      0 100.00000 ESR1 (ER)   Brain.N(3) FALSE
5      0 100.00000      PAX8   Brain.N(3) FALSE
6      3 100.00000 ESR1 (ER) Breast.M(11) TRUE
7      0 100.00000      PAX8 Breast.M(11) TRUE
8      0  36.36364 ESR1 (ER) Cervix.M(11) TRUE
9      1   9.09091 ESR1 (ER) Cervix.M(11) TRUE
10     2  18.18182 ESR1 (ER) Cervix.M(11) TRUE
11     3  36.36364 ESR1 (ER) Cervix.M(11) TRUE

palette <- palette(gray(seq(0, 1,len=4))) trellis.par.set(list(par.xlab.text=list(cex=0.85)

                   , superpose.polygon=list(col=palette())
                   , axis.text=list(cex=0.8)))
  
 
barchart(percent~cellType|marker

, groups=score
, data=myData
, stack=TRUE
, xlab='N=Normal/Benign, M=Malignant'
, ylab='Percentage of Cores Staining'
, color=palette()
, auto.key = list(points = FALSE, rectangles = TRUE, space = "top")
, scales=list(x=list(rot=70))
, layout=c(1,2))

I would like to make the color scheme of the bar differ according to the variable 'Malignant' and add a second color scheme to the key.  

Any help would be appreciated!
--Sarah  

Sarah Hawley
Data Coordinator/Analyst
Canary Foundation
sarah_at_canaryfoundation.org
415.412.2533

www.canaryfoundation.org
Stopping cancer early...
the best possible investment!



R-help_at_stat.math.ethz.ch 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. Received on Wed 06 Jun 2007 - 19:53:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Jun 2007 - 21:32:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.