[R] Re : Re : Adding mean line to a lattice density plot

Pascal Oettli kridox at ymail.com
Thu Mar 8 15:09:54 CET 2012

Hi Kimmo,

Unfortunately, I can't visualize the attachment. Could you provide an example I can reproduce?


----- Mail original -----
De : K. Elo <maillists at nic.fi>
À : r-help at r-project.org
Cc : 
Envoyé le : Jeudi 8 mars 2012 22h38
Objet : Re: [R] Re :  Adding mean line to a lattice density plot


thank you, Pascal, for your quick reply. Unfortunately your suggestion is not working. Please have a look on the attachment, I have added manually the mean lines I am trying to plot. The problem with 'abilne' seems to be that the argument 'v' is relative to the graph area, not the x-axis scale. Thus, plottingat v='mean' won't work...

Any suggestions?

Kind regards,

08.03.2012 09:49, Pascal Oettli wrote:
> Hi Kimmo,
> You can try to use the "layer" function from "latticeExtra" library:
> densityplot(~PV1CIV, groups=SGENDER, data=ISGFINC2,
>    lwd=2, col=1, lty=c(1,2), pch=c("+","o"),
>    key=list(text=list(lab=levels(ISGFINC2$SGENDER), col=1),
>    space="bottom", columns=2, border=T, lines=T, lwd=2,
>    lty=c(1,2), col=1), ref=T, plot.points=F) + layer(panel.abline(v=mean(PV1CIV[ SGENDER==1 ])))
> Regards,
> Pascal

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list