Problems with the scale 3d on animations

Dear all,
I have the following code to perform an animation in 3d:

using Plots 
plotlyjs()

anim = Animation()
for n in range(0,2π,length=10)
    t=0:0.1:n
    x=cos.(t)
    y=sin.(t)
    z=t
    scatter(x,y,z,lw=1,markersize = 0.5,color=:blue,xlabel="x",ylabel="y",zlabel="z",legend=false,size=(400,400),
            ratio=1)
    zlims!(0,7)
    xlims!(-2,2)
    ylims!(-2,2)
    frame(anim)
end
gif(anim,"TesteGif2.gif",fps=5)

whose output is the following:
TesteGif2
However, I would to keep the axes of the same length, without increasing or decreasing the scale, throughout the animation. How can I do this?

1 Like

It doesn’t seem to work with the PlotlyJS backend (at least I couldn’t get it working). And it’s unsupported for 3D axes with the PyPlot backend. But if you use the GR backend, you can do it with the keyword argument aspect_ratio=:equal instead of ratio=1.

using Plots 
gr()

anim = Animation()
for n in range(0,2π,length=10)
    t=0:0.1:n
    x=cos.(t)
    y=sin.(t)
    z=t
    scatter(x,y,z,lw=1,markersize = 2,color=:blue,xlabel="x",ylabel="y",zlabel="z",legend=false,size=(400,400),
            aspect_ratio=:equal)
    zlims!(0,7)
    xlims!(-2,2)
    ylims!(-2,2)
    frame(anim)
end
gif(anim,"TesteGif2.gif",fps=5)

TesteGif2
I had to make the marker size 2 to make it easier to see, though.

1 Like