Is there any way of adding text to a density plot? I have had a go using the
text() function but I think the error is because this function doesn't work
with densityplot().

Alternatively, I understand I can achieve pretty much the same result if I
plot a density kernel estimate using plot() (which allows text()), but I do
prefer densityplot().


Also, is it possible to specify the dimensions of a graphics device? I don't
mean the x and y limits of a plot, but rather can I change the dimensions of
the default (square) graphics device?

Many thanks
Murray


try <- (rnorm(100, mean = 5, sd = 3))
library(lattice)
trellis.device(col = FALSE, theme = lattice.getOption("col.whitebg"))
densityplot(~try)
normtest <- shapiro.test(try)
normtest
pvalue <- round(normtest$p.value,5)
normtext <- paste(normtest$method,"p-value =",pvalue)
normtext
xcoord <- max(try)*0.6
text(xcoord,0.1,normtext)


# alternative

plot(density(try))
text(0,0.1,normtext)

-- 
Murray Pung
Statistician, Datapharm Australia Pty Ltd
0404 273 283

	[[alternative HTML version deleted]]

