[R] 3D trajectory plot?
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Nov 14 11:41:20 CET 2008
On 14/11/2008 3:10 AM, Yihui Xie wrote:
> But it's not _smooth_ (as Chris asked for)... I also thought about the
> plot3d(), but I don't know how to smooth the 3D points. AFAIK spline
> functions only work for 2D cases in R? (Sorry I'm not familiar with
> splines)
There are lots of definitions of smooth. One easy one is to use splines
in each coordinate, with the independent variable being an implied time
coordinate 1, 2, 3, etc. That is (with only the first 4 points, I'm lazy):
x <- splinefun(1:4, c(25,12,2,2))
y <- splinefun(1:4, c(32,25,12,2))
z <- splinefun(1:4, c(40,32,25,12))
times <- seq(1, 4, len=200)
plot3d(x(times), y(times), z(times), type="l")
Duncan Murdoch
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
> Mobile: +86-15810805877
> Homepage: http://www.yihui.name
> School of Statistics, Room 1037, Mingde Main Building,
> Renmin University of China, Beijing, 100872, China
>
>
>
> On Wed, Nov 12, 2008 at 7:22 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>> Chris Jarman wrote:
>>> Hello,
>>> I'm attempting to create a smooth, 3D plot of a trajectory (rather
>>> than the cloud or wireframe functions). I would rather the individual
>>> data points not be visible. I've had no luck finding this on the
>>> graphics or help pages. Thank you in advance. Chris
>>> Some example data, just in case:
>>>
>>> 25 32 40
>>> 12 25 32
>>> 2 12 25
>>> 2 2 12
>>> 20 2 2
>>> 1 20 2
>>> 6 1 20
>>> 5 6 1
>>> 5 5 6
>>>
>>>
>> plot3d(x,y,z, type='l') from rgl.
>>
>> Duncan Murdoch
>>
>
> ______________________________________________
> 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