[R] how to add 3d-points to bplot {rms} figure?
David Winsemius
dwinsemius at comcast.net
Tue Apr 10 04:39:38 CEST 2012
On Apr 9, 2012, at 6:24 PM, phi771 wrote:
> Hello!
> I have created a bplot-figure using this code:
>
> *file <- "2dcali_red.ttt"
> ux<-as.matrix(read.table(file, dec = ","))
>
> mode(ux)<-'numeric'
>
> vel<-ux[,1]
> ang<-ux[,2]
> x<-ux[,3]
> y<-ux[,4]
>
> dat<- data.frame(ang=ang, x=x,y=y)
>
> require(rms)
>
> ddist2 <- datadist(dat)
> options(datadist="ddist2")
>
> fitn <- lrm(ang ~ rcs(x,4) + rcs(y,4), data=dat)
> predi <- Predict(fitn, x, y)
>
> bplot(predi,lfun=wireframe, screen = list(z = -40, x = -80),
> drape=TRUE)*
>
> The file 2dcali_red.ttt consists of 4 columns can be found here :
> http://www.color-space.de/upload/dl/2dcali_red.ttt link
>
> The code gives me the bplot-figure, which looks like this:
> http://r.789695.n4.nabble.com/file/n4544050/Screen_shot_2012-04-10_at_12.04.24_AM.png
>
> Now I want to add some 3d data (x,y,z) to this plot (like
> scatterplot3d),
> but i don't know how. I also don't know how to extract the x,y,z
> mesh as
> coordinates from the bplot. Some help would be very appreciated.
> Thank you!
That is most probably a lattice::wireframe object. You could use
'trellis.focus' or the 'layer' functions in pkg::latticeExtra to
attempt panel.3dbars() additions. I haven't actually done this, but I
have added panel function results to the lattice::contourplots that
are created byrms/Hmisc.
The 3d aspect adds a significant level of extra work: http://tolstoy.newcastle.edu.au/R/e2/help/06/10/3274.html
Maybe a contourplot would suffice?
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list