[R] highlight points in lattice cloud plot
Duncan Mackay
mackay at northnet.com.au
Thu May 30 05:28:43 CEST 2013
Hi Stefan
Not a perfect solution but may get you some of the way.
I can't spend any more time on it
I think your groups argument is not valid so made a groups argument
Try this
data_xyz$gp <- sapply(data_xyz$a == 1, pmatch, c(TRUE,FALSE))
cloud(z ~ x*y|b, data=data_xyz,
groups= gp,
panel = function(x,y, subscripts, groups, xlim,...){
pnl <- panel.number()
if (pnl == 1){
panel.cloud(x, y, z, subscripts = subscripts,
groups=groups, type='p', xlim = xlim, ...)
panel.cloud(x, y, z, type='p', pch=18,xlim = xlim, ...)
} else {
panel.cloud(x, y, z, subscripts = subscripts,
groups=groups, type='p', xlim = xlim, ...)
panel.cloud(x, y, z, type='b',
col="tomato3",xlim = xlim, ...)
}
}
)
HTH
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 23:57 29/05/2013, you wrote:
>Sorry forthat and thanks for the hint.
>
>At marked the appended text as "rawtext", maybe that is the reason why
>it was cut.
>
>Here we go again.
>
>##################################################################
>
>x=runif(100, 1, 2)
>y=runif(100, 2, 4)
>z=runif(100, 1, 4)
>
>
>### 2d example
>data_xy=as.data.frame(cbind(x, y, a=rep(c(1:10), 10), b=rep(c(1:2),
>each=50)))
>
>custom.panel = function(x, y, subscripts, ...)
>{
>highlight=(data_xy$a == 1)
> highlight.panel = highlight[subscripts]
>
>panel.xyplot(x[highlight.panel], y[!highlight.panel],
> type='p', pch=18)
>panel.xyplot(x[highlight.panel], y[highlight.panel],
> type='b', col="tomato3")
>}
>
>xyplot(x~y|b, data=data_xy, groups=a,
>panel=custom.panel)
>
>### 3d example
>data_xyz=as.data.frame(cbind(x, y, z, a=rep(c(1:10), 10), b=rep(c(1:2),
>each=50)))
>
>custom.panel = function(x, y, z, subscripts, ...)
>{
>highlight=(data_xyz$a == 1)
> highlight.panel = highlight[subscripts]
>
>panel.cloud(x[highlight.panel], y[!highlight.panel], z[!highlight.panel],
> type='p', pch=18)
>panel.cloud(x[highlight.panel], y[highlight.panel], z[highlight.panel],
> type='b', col="tomato3")
>}
>
>#that works of course
>cloud(z~x*y|b, data=data_xyz)
>
>#that not
>cloud(z~x*y|b, data=data_xyz, groups=TRUE,
>panel=custom.panel)
>
>
>##################################################################
>
>On 05/29/2013 03:36 PM, John Kane wrote:
> > No attachment. The R-help list tendst to strip out many type of
> attached files though pdf and txt , among others get through.
> >
> > It is better to supply the example in the email itself if
> possible. Have a look at
> https://github.com/hadley/devtools/wiki/Reproducibility for suggestions.
> >
> > John Kane
> > Kingston ON Canada
> >
> >
> >> -----Original Message-----
> >> From: sluedtke at gfz-potsdam.de
> >> Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT)
> >> To: r-help at r-project.org
> >> Subject: [R] highlight points in lattice cloud plot
> >>
> >> Dear list,
> >>
> >> I am
> >> struggling with the following problem.
> >>
> >> In a 2d case I managed to highlight a subset of points through the
> >> panel.xyplot function.
> >>
> >> However, I was trying the same in 3d using panel.cloud, but now luck.
> >>
> >> I attached a minimal example, I think the first plot shows the idea.
> >>
> >> Thanks,
> >>
> >> Stefan
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> ______________________________________________
> >> R-help at 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.
> > ____________________________________________________________
> > FREE ONLINE PHOTOSHARING - Share your photos online with your
> friends and family!
> > Visit http://www.inbox.com/photosharing to find out more!
> >
> >
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at 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.
More information about the R-help
mailing list