Hi there David, Many thanks for your time and reply
I created a small test set, and ran your proposed solution... and this is what I get http://i.imgur.com/vlsSQ.png This is not what I want - I want separate grp_1 and grp_2 panels and in each panel a red violin plot and a blue one. So like this --> http://i.imgur.com/NnsE0.png but with red for condition_a and blue for condition_b. You would think that something like this is trivial to achieve... I just spent a whole day on this :(( Maybe I am just thick I included the test data I am using: # some dummy data p <- rep(c(rep("condition_a", 4), rep("condition_b", 4)), 2) q <- c(rep("grp_1", 8), rep("grp_2", 8)) r <- rnorm(16) test_data <- data.frame(p, q, r) # your solution bwplot(r ~ p, groups = q, data=test_data, col = c("red", "blue"), panel=panel.superpose, panel.groups = function(..., box.ratio){ panel.violin(..., cut = 1, varwidth = FALSE, box.ratio = box.ratio) panel.bwplot(..., box.ratio = .1) }, par.settings = list(plot.symbol = list(pch = 21, col = "gray"), box.rectangle = list(col = "black"), # not sure these are working properly box.umbrella = list(col = "black")) ) # my non working one for completeness bwplot(r ~ p | q, data=test_data, col = c("red", "blue"), panel = function(..., box.ratio){ panel.violin(..., cut = 1, varwidth = FALSE, box.ratio = box.ratio) panel.bwplot(..., box.ratio = .1) }, par.settings = list(plot.symbol = list(pch = 21, col = "gray"), box.rectangle = list(col = "black"), # not sure these are working properly box.umbrella = list(col = "black")) ) On 24 March 2011 21:59, David Winsemius <dwinsem...@comcast.net> wrote: > > On Mar 24, 2011, at 1:37 PM, JP wrote: > > Using Trellis, am successfully setting up a number of panels (25) in which >> I >> have two box and violin plots. >> >> I would like to colour - one plot as RED and the other as BLUE (in each >> panel). I can do that with the box plots, but the violin density areas >> just >> take on one colour. >> >> My basic call is as follows: >> >> > I took the suggestion of Sarkar's: > http://finzi.psych.upenn.edu/Rhelp10/2010-April/234191.html > > Identified with a search on: " panel.violin color" > > .... a bit of trial and error with a re-worked copy of the `singer` > data.frame meant I encountered errors and needed to throw out some of your > pch arguments, and suggest this reworking of your code: > > > bwplot(rmsd ~ file , groups= code, > data=spread_data.filtered, col = c("red", "blue"), > panel=panel.superpose, > panel.groups = function(..., box.ratio){ > panel.violin(..., cut = 1, varwidth = FALSE, > box.ratio = box.ratio) > panel.bwplot(..., box.ratio = .1) > > }, > par.settings = list(plot.symbol = list(pch = 21, col = "gray"), > box.rectangle = list(col = "black"), # not sure these are working > properly > > box.umbrella = list(col = "black")) > ) > > Obviously it cannot be tested without some data, but I did get alternating > colors to the violin plots. There is an modifyList functionthat you might > want to look up in the archives for changing par.settings: > > > http://search.r-project.org/cgi-bin/namazu.cgi?query=par.settings+modifyList&max=100&result=normal&sort=score&idxname=functions&idxname=Rhelp08&idxname=Rhelp10&idxname=Rhelp02 > > > -- > > David Winsemius, MD > West Hartford, CT > > -- Jean-Paul Ebejer Early Stage Researcher InhibOx Ltd Pembroke House 36-37 Pembroke Street Oxford OX1 1BP UK (+44 / 0) 1865 262 034 This email and any files transmitted with it are confide...{{dropped:22}} ______________________________________________ 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.