[R] 3D plots with data.frame

Duncan Murdoch murdoch at stats.uwo.ca
Sat May 26 02:54:54 CEST 2007


On 25/05/2007 8:22 PM, J.delasHeras at ed.ac.uk wrote:
> 
> 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)

Or more simply, plot3d(x) (which plots the 1st three columns).

Duncan Murdoch
> 
> 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.
>>
>>
> 
> 
>



More information about the R-help mailing list