Skip to content

Using panel.densityplot with stripplot

4 messages · Christopher Oezbek, Deepayan Sarkar

#
Hi Lattice-Experts/Hi Deepayan,
   I have been searching the archives for an answer to this, but am finally  
giving up:

I am plotting stripplots above each other using

stripplot(type ~ date, data = email)

which looks exactely as I want (type is a factor with 8 levels). I  
addition I would now like to display for each stripplot a density curve.

 From examples I would have thought I would need to do:

stripplot(type ~ date2, data = email,
           panel = function(x, y, ...) {
             panel.stripplot(x, y, ...)
             panel.densityplot(x, y, ...)
           })

This works as far as the stripplot part is concerned. But

a.) panel.densityplot does not take a y argument.

b.) even if I drop y, no density curve shows up (I guess I am missing  
correct dargs here)

I have been toying with

- using panel.superpose but guess that this is not the right approach,  
since I do not have a grouping variable (and I have not succeeded in  
letting "~ date2 | type" and "~date, groups=email$type" look the way I  
want).

- using densityplot instead of stripplot, but then panel.stripplot  
complains that argument y is missing. :-(

Many thanks for any advice/ideas!
   Christopher
#
On 12/6/07, Christopher Oezbek <oezbek at inf.fu-berlin.de> wrote:
What examples? panel.stripplot and panel.densityplot have entirely
different expectations about what the y-range of the panel is going to
be, and they cannot be mixed.

Sounds like you want something like panel.violin (?panel.violin has an example).

-Deepayan
#
Hi Deepayan!
   thank you! panel.violin with the following modification works as I want:

grid.polyline(x = dx.list[[i]], y = dy.list[[i]], ...

instead of

grid.polygon(x = c(dx.list[[i]], rev(dx.list[[i]])),
                 y = c(dy.list[[i]], -rev(dy.list[[i]])), ...
The examples for writing your own panel functions. I was not aware that  
there were different expectations regarding arguments.
But is there a technical reason for making this distinction? It seemed to  
me that most panel functions can deal with x and y parameters and that  
panel.densityplot could make use of the same mechanisms as panel.violin to  
subdivide based on factor y.

Again many thanks for the fast response,
   Christopher
#
On 12/6/07, Christopher Oezbek <oezbek at inf.fu-berlin.de> wrote:

            
The technical reason is a fundamental part of the Trellis design. The
prepanel function determines a bounding box as part of the initial
calculations. Knowing this in advance allows the panel display and the
axis rendering to be completely separated.

Note that the panel.violin plot cannot easily say anything about the
actual heights of the densities, only their shape. The y-axis there
annotates the sample groups.

-Deepayan