Hi, lattice graphics work by utilizing so called panel functions. Here is a working version of your example:
library(lattice) x<-rnorm(100) plot.new() densityplot(x, panel=function(x, ...){ panel.densityplot(x, ...) panel.abline(v=0) } ) For mor information, please look into the examples of densityplot and the help file of panel.abline Hope it helps Thomas Gustaf Rydevik wrote: > Hi all, > > I'm trying to get a vertical line at a specific point in a > densityplot. abline seems to be what's required, but it doesn't align > itself to the scale used in the plot. > > example: > > library(lattice) > x<-rnorm(100) > plot.new() > densityplot(x) > abline(v=0) > ----- > The line seems to use some other coordinate system. What kind of call > do I use to make abline use the graph's coordinates? > > Additionally, it would be nice to have standard xy-axis, and to have > the line stop at the x-axis, so if anyone could tell me how to do > that, I'd be grateful. What is a "standard x achsis?". > Thanks in advance, > > Gustaf > > > PS: a minor question: Why do I have to call plot.new() for abline to work? > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.