Skip to content
Back to formatted view

Raw Message

Message-ID: <20090220111155.GA8102@localhost>
Date: 2009-02-20T11:11:55Z
From: Philipp Pagel
Subject: adding a reference line to an xyplot
In-Reply-To: <22117545.post@talk.nabble.com>

On Fri, Feb 20, 2009 at 01:34:02AM -0800, Chris Bennett wrote:
> I want to add a dashed vertical line to a number of xyplots.
> 
> Here is a simple script of the type of plot I have but then I want to add a
> reference line to 1995 on each of the panels.  I have tried panel.abline and
> other suggestions on the forum but can't get it to work.
> 
> plot<-rep(letters[1:3],each=10)
> year<-rep(1991:2000,times=3)
> matter<-rep(seq(2,6.5,0.5),times=3)
> xyplot(matter~year|plot,type="l")

The panel function is the way to go:

xyplot( matter~year|plot,
	type="l",
	panel=function(...){
		panel.xyplot(...)
		panel.abline(v=1995)
	}
)


BTW: it is not a good idea to use the name of builting functions as a
variable name (plot).

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f?r Genomorientierte Bioinformatik
Technische Universit?t M?nchen
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel