> > I need a quick help with the following graph (I'm a lattice newbie):
> > 
> > require("lattice")
> > npp=1:5
> > names(npp)=c("A","B","C","D","E")
> > barchart(npp,origin=0,box.width=1)
> > 
> > # What I want to do, is add a single vertical line 
> positioned at x = 2
> > that lays over the bars (say, using a dotted line).  How do 
> I go about
> > doing this?

In a lattice call, you can use panel= to provide a panel function that does 
more than one thing per panel. In this case:

npp=1:5
names(npp)=c("A","B","C","D","E")
barchart(npp,origin=0,box.width=1,
        panel=function(x, y, ...) {
             panel.barchart(x, y, ...)
             panel.abline(v=2, lty=2)
        }
)

This gets more useful with grouped data because the panel function picks up the 
grouping factor:

g <- gl(5,5)
h <- factor(rep(LETTERS[1:5], 5))
barchart(h~ppn|g,origin=0,box.width=1,
        panel=function(x, y, ...) {
             panel.barchart(x, y, ...)
             panel.abline(v=2, lty=2.5)
        }
)

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
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.

Reply via email to