change view, plot3D, Julia language (similar to ma

2020-07-22 09:48发布

问题:

I'm trying to change the perspective of a 3D scatter plot. (Julia Language)

This code, for example, changes the perspective, but the points are plotted individually with each change, rather than together.

for i=1:10
    X=i; Y=i+2; Z = i+3
    fig = figure()
    ax = gca(projection="3d")
    plot3D([X],[Y],[Z], ".")
    ax[:view_init](30, 180)
end

How can I write this so that I see all the points together in a changed perspective? The format in Julia is adapted from matplotlib, so it should be very similar to how it is accomplished in Julia.

回答1:

Just take the figure creation out of the loop. You are creating a new figure in each iteration.

using PyPlot

fig = figure()
ax = gca(projection="3d")

for i=1:10
    X=i; Y=i+2; Z = i+3
    plot3D([X],[Y],[Z], ".")
    ax[:view_init](30, 180)
end

Does that do what you want?