change view, plot3D, Julia language (similar to matplotlib)

為{幸葍}努か 提交于 2019-12-06 09:05:23

问题


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?



来源:https://stackoverflow.com/questions/38837539/change-view-plot3d-julia-language-similar-to-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!