3

I have data which is movement of an object in 3D space at regular time intervals. Data is as below:

Time  X   Y   Z
1     1   1   1
2     2   1   2
3     2   0   1
4     3   2   1
.....

(x,y,z) is the position of object at time t. I want to plot a 3D graph where it shows the complete movement of object in 3d space, but to have a slider or something of that sort where I can select a time range (say 500 to 750) and see the movement of the object in 3D space. So, here we have 4 dimensions: x,y,z are positions and time as 4th dimension and use a slider to control the plotting of points with in that time. [Example in Mathematica below gives a good idea about this]

To make it more clear. We first draw the complete movement of the object in 3D space from time 1 to N. Then, by controlling the slider, we draw the movement of same object between t1 to t2 time stamps. It is also important to display at what time the slider is at (as I have to make a note of some interested time stamps based on the movement).

I have Googled the same, but no example was close enough to get me what I want. All of those bind the slider to one of the axis variables (say x or y which might be time) but we have to bind it to 4th dimension, time. dygraphs was promising but I had similar issues as discussed above (also, didn't find any 3d support).

This one in Mathematica is interesting. But I don't have license for it. It just moves a point on the 3D path traced. This can solve my problem as well, but I should be able to know the time-stamp values when I pause it.

Solution in R is good for me because it does not have any licensing issues. Or in Matlab if it does not use any advanced visualization toolboxes. Or Python.

Thanks in Advance.

Community
  • 1
  • 1
inblueswithu
  • 953
  • 2
  • 18
  • 29

1 Answers1

4

This is a raw example that can be customized as desired. It uses manipulate and plot3D

library(manipulate)
library(plot3D)

min_time <- 1
max_time <- 100
time_interval <- min_time:max_time

# Create data frame
DF <- data.frame(t = time_interval)

# Time parametric functions
X <- function(t) {
  return(2 * t)
}

Y <- function(t) {
  return(t ** 2)
}

Z <- function(t) {
  return(10 * cos(t / 100))
}
# Update data frame
DF$x <- sapply(DF$t, X)
DF$y <- sapply(DF$t, Y)
DF$z <- sapply(DF$t, Z)

# Use manipulate with RStudio
manipulate({
  lines3D(x = DF$x, y = DF$y, z = DF$z)
  scatter3D(
    x = DF$x[t],
    y = DF$y[t],
    z = DF$z[t],
    add = TRUE
  )
}, t = slider(min_time, max_time))

enter image description here

Enrique Pérez Herrero
  • 3,699
  • 2
  • 32
  • 33
  • 1
    This is pretty close. Can it animate the movement by any chance? B'se I have to manually move the slider to each position and wait to see the pointer move. I may be expecting more, but that helps me. Thanks once again! – inblueswithu Sep 14 '16 at 21:10
  • 1
    Also, I actually wanted to redraw the plot based on time bounds, so that I can see the movement of object. – inblueswithu Sep 14 '16 at 21:16
  • 1
    Also: http://stackoverflow.com/questions/1298100/creating-a-movie-from-a-series-of-plots-in-r and http://www.programmingr.com/content/animations-r/ – Enrique Pérez Herrero Sep 14 '16 at 21:18
  • 1
    Infact, this graph does not help much. I need to plot the movement of the object between t1 to t2. Or An animation which can help me find that t1 to t2 along with observing the path in which it traveled (having a path trail already in place as in that Mathematica example is essential). Also, I was unable to rotate the axis to see from different angles. All this is critical to my job as I have to observe this over a long period of time say 1500 time stamps in a small region, so, there will be lot of overlapping positions in motion. That is why I have been picky or rigid in my requirements. – inblueswithu Sep 15 '16 at 19:51
  • I'm not even sure if this is even possible in R or in python. – inblueswithu Sep 15 '16 at 19:58
  • Those links which help to convert into gifs or movie clips are not helpful as I am wanting to have interactive graphs (not static). – inblueswithu Sep 15 '16 at 20:03