[R] Colour makes my life; but not my bwplot (panel.violin)

David Winsemius dwinsemius at comcast.net
Thu Mar 24 22:59:19 CET 2011


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



More information about the R-help mailing list