Hi r-help-boun...@r-project.org napsal dne 03.02.2009 09:20:25:
> David Scott <d.scott <at> auckland.ac.nz> writes: > > > > > > > I would like to add some vertical lines to a lattice plot of histograms. > > What I am after is a lattice version of abline(v = 1234). The lattice > > histogram plot is just: > > > > histogram( ~ LTSE | approach, data = arrivals) > > > > As a little variation on the histogram docs example: > > histogram( ~ height | voice.part, data = singer, > xlab = "Height (inches)", type = "density", > panel = function(x, ...) { > panel.histogram(x, ...) > panel.abline(v= 70) > panel.mathdensity(dmath = dnorm, col = "black", > args = list(mean=mean(x),sd=sd(x))) > } ) > > Or if you want add lines at different places in each panel use this function and set once =T addLine<- function(a=NULL, b=NULL, v = NULL, h = NULL, ..., once=F) { tcL <- trellis.currentLayout() k<-0 for(i in 1:nrow(tcL)) for(j in 1:ncol(tcL)) if (tcL[i,j] > 0) { k<-k+1 trellis.focus("panel", j, i, highlight = FALSE) if (once) panel.abline(a=a[k], b=b[k], v=v[k], h=h[k], ...) else panel.abline(a=a, b=b, v=v, h=h, ...) trellis.unfocus() } } Regards Petr > Dieter > > ______________________________________________ > R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.