[R] Multiple color schemes for barchart (lattice)
Sarah Hawley
sarah at canaryfoundation.org
Wed Jun 6 21:44:11 CEST 2007
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!
More information about the R-help
mailing list