Issues with animation by plotting via for-loops

Hi,

I have x,y,z coordinates over time for a few points on a moving object, that i want to animate using Julia. In the end, i would like to have an interactive animation that can be rotated while the animation is running, but im trying to take baby steps here. So a gif/video of the actual movement, maybe with a rotating camera is my current goal.

The input is a CSV file which i read and convert:

movement = convert(Matrix,CSV.read("data.csv"))

The array movement becomes a 1118x37 Array{Float64,2} after this operation, and i can successfully plot the path of one of the points using:

scatter3d(movement[:,1],movement[:,2],movement[:,3])

Now to the problem, when i try to animate following the two examples on https://docs.juliaplots.org/latest/animations/, i get the following:

Example 1

anim = @animate for i=1:100
    scatter3d(movement[i,2],movement[i,4],movement[i,3])
end
gif(anim, "out.gif", fps=15)

Example 2

@gif for i=1:100
    scatter3d(movement[i,2],movement[i,4],movement[i,3])
end every 10

Here i gave up and tried to just plot a single value plot(movement[1,2],movement[1,4],movement[1,3])

Output in all cases:

"ERROR: Cannot convert Float64 to series data for plotting"

I am using Plots with the plotly backend.
What am i missing? Why cant i even just plot a simple point in 3D using scatter? If i input some random decimal numbers manually it works just fine, but for some reason when i specify them from the array, it does not work.

Thanks in advance for any advice!

You are trying to plot scalars (e.g. (movement[i,2])) but plot expects Vectors. The distinction between scalars and vectors might be surprising if you’re used to R or matlab (where scalars don’t exist and everything is a vector/matrix).
To plot a single point, use a length 1 vector, e.g. by indexing with a range: scatter3d(movement[i:i,2],movement[i:i,4],movement[i:i,3])

2 Likes