Skip to content
Prev 286105 / 398502 Next

Several densityplots in single figure

On Wed, Feb 22, 2012 at 8:49 AM, David Winsemius <dwinsemius at comcast.net> wrote:

            
Close, but unfortunately things get more complicated when using groups
in densityplot. A straight up panel function wouldn't work for him out
of the box (and you/list be getting more follow ups). He'll need
something like:
densityplot(~value | g1, groups=g2, data= combinedlongformat,
 panel=panel.superpose, panel.groups=function(x,...,group.number){
 panel.abline(v=mean(x),lwd=(1:0)[group.number])  # seems like he only wants x1
 panel.densityplot(x,...)
 })

At this stage in the game
trellis.focus('panel',1,1) ; panel.abline(v=calculatedmean1)
trellis.focus('panel',2,1) ; panel.abline(v=calculatedmean2)
...
trellis.unfocus()

Would probably go down easier...

Just a thought

Cheers,
Elai


You