4

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.

haxtar
  • 1,962
  • 3
  • 20
  • 44
  • 3
    Julia has over half a dozen plotting libraries. I am guessing you are using PyPlot, which is the wrapper for matplotlib. But are you using it directly or via Plots.jl, or ... Can you specify exactly what plot library you are using? You MWE, should include all `using`/`import`/`importall` lines. And the names of the Packages ideally too. – Frames Catherine White Aug 09 '16 at 01:54

1 Answers1

5

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?

Alexander Morley
  • 4,111
  • 12
  • 26