Message-ID: <eb555e660911200035j1b270fe7ib18420f204c26007@mail.gmail.com>
Date: 2009-11-20T08:35:56Z
From: Deepayan Sarkar
Subject: Hmisc and Lattice question on gridlines
In-Reply-To: <012101ca6987$a7f6ef00$f7e4cd00$@com>
On Fri, Nov 20, 2009 at 7:47 AM, Joe King <jp at joepking.com> wrote:
> I have been using lattice xyplot and am quite pleased, and I can use the
> type=c("b","g") to have it print gridlines into the page, yet if I want to
> have a line plot with points on it, how do I get the xYplot to print
> gridlines (I use Hmisc xYplot because of its bands method which allows
> plotting of confidence intervals). Any suggestions? I have looked at the
> panel functions but when I try it I get the gridlines but my data is gone.
>
>
>
> So a simple example is below. I want to create the reference lines in the
> lattice plot in the xYplot from Hmisc so I can keep the confidence intervals
> filled.
>
>
>
> x<-seq(1,10,1)
>
> y<-seq(1,10,1)
>
> ci<-y*.10
>
> ciupper<-y+ci
>
> cilower<-y-ci
>
>
>
> xyplot(y~x, type=c("b","g"),plot.points = TRUE)#using lattice
>
>
>
> xYplot(Cbind(y,cilower,ciupper)~x,col.fill="grey",plot.points =
> TRUE,type=c("b"),method="filled bands")#using Hmisc
As ?panel.xyplot tells you, type="g" is just a shortcut that calls
panel.grid(), so you get the equivalent effect with
xYplot(Cbind(y,cilower,ciupper)~x,col.fill="grey",plot.points = TRUE,
type="b",method="filled bands",
panel = function(...) {
panel.grid(h = -1, v = -1)
panel.xYplot(...)
})
-Deepayan