[R] Palette color order in bwplot (lattice violin plot) vs. boxplot

Felix Andrews felix at nfrac.org
Thu Apr 8 02:11:54 CEST 2010


On 8 April 2010 03:34, Luigi Ponti <lponti at inbox.com> wrote:

> Thanks for the hint, Felix: the following code makes it but (don't know why)
> the median dots disappear.
>
> bwplot(count ~ spray, data = InsectSprays,
>        groups = spray,
>        panel = panel.superpose,
>        panel.groups =  function(..., box.ratio) {
>             panel.violin(...,
>                          varwidth = FALSE, box.ratio = box.ratio, cut = 0)
>             panel.bwplot(..., box.ratio = .1)
>         },
>         fill = MyPalette
> )
>
> I tried to change box.dot parameter to no avail. Not sure what is going on
> here. It would appear that the panel.groups = function(){} is not sure where
> to read graphical parameters from (just guessing). It would be interesting
> to know your opinion.

The problem is that panel.superpose() passes on arguments 'col.line'
and 'col.symbol', but unless otherwise specified, 'col' is passed as
NA (which is an invisible color). Your options are to specify pch =
"|", which is not affected by 'col', or to pass 'col' explicitly:

bwplot(count ~ spray, data = InsectSprays,
       groups = spray,
       panel = panel.superpose,
       panel.groups =  function(..., box.ratio, col) {
            panel.violin(..., col = col,
                         varwidth = FALSE, box.ratio = box.ratio, cut = 0)
            panel.bwplot(..., col = "black", box.ratio = .1)
        },
        fill = MyPalette, pch = 16
)




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



More information about the R-help mailing list