[R] 3D plots with data.frame

J.delasHeras at ed.ac.uk J.delasHeras at ed.ac.uk
Sat May 26 02:22:56 CEST 2007



You could try the function 'plot3d', in package 'rgl':

library(rgl)
?plot3d
x<-data.frame(a=rnorm(100),b=rnorm(100),c=rnorm(100))
plot3d(x$a,x$b,x$c)

Jose


Quoting "H. Paul Benton" <hpbenton at scripps.edu>:

> Dear all,
>
>     Thank you for any help. I have a data.frame and would like to plot
> it in 3D. I have tried wireframe() and cloud(), I got
>
> scatterplot3d(xs)
> Error: could not find function "scatterplot3d"
>
>> wireframe(xs)
> Error in wireframe(xs) : no applicable method for "wireframe"
>
>> persp(x=x, y=y, z=xs)
> Error in persp.default(x = x, y = y, z = xs) :
>         (list) object cannot be coerced to 'double'
>> class(xs)
> [1] "data.frame"
> Where x and y were a sequence of my min -> max by 50 of xs[,1] and xs[,2].
>
> my data is/looks like:
>
>> dim(xs)
> [1] 400   4
>> xs[1:5,]
>         x       y     Z1     Z2
> 1 27172.4 19062.4      0    128
> 2 27000.9 19077.8      0      0
> 3 27016.8 19077.5      0      0
> 4 27029.5 19077.3      0      0
> 5 27045.4 19077.0      0      0
>
>     Cheers,
>
>     Paul
>
> --
> Research Technician
> Mass Spectrometry
>    o The
>   /
> o Scripps
>   \
>    o Research
>   /
> o Institute
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>



-- 
Dr. Jose I. de las Heras                      Email: J.delasHeras at ed.ac.uk
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK



More information about the R-help mailing list