Grokbase Groups R r-help May 2008
FAQ
Hello,

I am using xYplot to plot lines with confidence bands (see test
example below). I would like to add a single point with
confidence bars to each graph (coordinates of the points below:
px, py, pxlow, etc...). I tried playing with
panel=panel.superpose, but failed to get it to work. Any ideas on
how to add these points to the graphs?

Thanks for your help,
John


## Test example

x1=seq(1,30,0.5)
y1=x1^2
y2*(x1^2)
ycomb=c(y1,y2)
y.up=ycomb+0.1*ycomb
y.low=ycomb-0.1*ycomb
grp=rep(c("Anls","Plts"),each=length(x1))
dat=as.data.frame(cbind(ycomb, y.up, y.low,
rep(x1,2)),stringsAsFactors=F)
colnames(dat)=c("ycomb","y.up","y.low","x1")
py=c(200,2000); pylow=c(190,1900); pyhi=c(210,2100)
px=c(0,0); pxlow=c(0,0); pxhi=c(0,0)

with(dat,xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp),
dataÚt,type="l", method="filled bands", col.fill="light
grey",

scales=list(y=list(relation="free"),x=list(alternating=c(1,1,1))),
ylim=list(c(0,1200),c(0,10000)),
strip=strip.custom(factor.levels=c(expression("Anls
km"^2),expression("Plants km"^2)))))

-------------------------------
John Poulsen
223 Bartram Hall PO Box 118525
University of Florida
Gainesville, FL 32611-8525

Search Discussions

  • Deepayan Sarkar at May 5, 2008 at 7:38 pm

    On 5/5/08, John Poulsen wrote:

    Hello,

    I am using xYplot to plot lines with confidence bands (see test example
    below). I would like to add a single point with confidence bars to each
    graph (coordinates of the points below: px, py, pxlow, etc...). I tried
    playing with panel=panel.superpose, but failed to get it to work. Any ideas
    on how to add these points to the graphs?
    If you want to add the same lines/points in all panels, you could
    write a not-too-complicated custom panel function; e.g.,

    with(dat,
    xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp),
    data=dat,type="l",
    method="filled bands",
    col.fill="light grey",
    subscripts = TRUE,
    panel = function(...) {
    panel.xYplot(...)
    panel.segments(pxlow, pylow, pxhi, pyhi)
    },
    scales=
    list(y=list(relation="free"),
    x=list(alternating=c(1,1,1))),
    ylim=list(c(0,1200),c(0,10000))))

    -Deepayan
  • John Poulsen at May 9, 2008 at 2:28 pm
    Hello Deepayan,

    Thanks for the below solution to my graphing problem - just what I
    was looking for.

    One quick additional question, where do I change graphical
    settings (lwd, pch, etc...) for the added points?

    Thanks,
    John
    On 5/5/08, John Poulsen wrote:


    Hello,

    I am using xYplot to plot lines with confidence bands (see
    test example
    below). I would like to add a single point with confidence
    bars to each
    graph (coordinates of the points below: px, py, pxlow, etc...). I tried
    playing with panel=panel.superpose, but failed to get it to
    work. Any ideas
    on how to add these points to the graphs?
    If you want to add the same lines/points in all panels, you could
    write a not-too-complicated custom panel function; e.g.,

    with(dat,
    xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp),
    data=dat,type="l",
    method="filled bands",
    col.fill="light grey",
    subscripts = TRUE,
    panel = function(...) {
    panel.xYplot(...)
    panel.segments(pxlow, pylow, pxhi, pyhi)
    },
    scales=
    list(y=list(relation="free"),
    x=list(alternating=c(1,1,1))),
    ylim=list(c(0,1200),c(0,10000))))

    -Deepayan




    -------------------------------
    John Poulsen
    223 Bartram Hall PO Box 118525
    University of Florida
    Gainesville, FL 32611-8525
  • John Poulsen at May 9, 2008 at 5:40 pm
    Hello Deepayan,

    Please ignore my last e-mail and question. The information was
    easily found in ?panel.segments.

    Thanks,
    John

    On 5/5/08, John Poulsen wrote:


    Hello,

    I am using xYplot to plot lines with confidence bands (see
    test example
    below). I would like to add a single point with confidence
    bars to each
    graph (coordinates of the points below: px, py, pxlow, etc...). I tried
    playing with panel=panel.superpose, but failed to get it to
    work. Any ideas
    on how to add these points to the graphs?
    If you want to add the same lines/points in all panels, you could
    write a not-too-complicated custom panel function; e.g.,

    with(dat,
    xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp),
    data=dat,type="l",
    method="filled bands",
    col.fill="light grey",
    subscripts = TRUE,
    panel = function(...) {
    panel.xYplot(...)
    panel.segments(pxlow, pylow, pxhi, pyhi)
    },
    scales=
    list(y=list(relation="free"),
    x=list(alternating=c(1,1,1))),
    ylim=list(c(0,1200),c(0,10000))))

    -Deepayan




    -------------------------------
    John Poulsen
    223 Bartram Hall PO Box 118525
    University of Florida
    Gainesville, FL 32611-8525

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedMay 5, '08 at 5:10p
activeMay 9, '08 at 5:40p
posts4
users2
websiter-project.org
irc#r

2 users in discussion

John Poulsen: 3 posts Deepayan Sarkar: 1 post

People

Translate

site design / logo © 2022 Grokbase