matplotlib - Plot sphere with Julia and PyPlot -
recently tried plot sphere using pyplot/julia , unfortunately harder thought. there's wrong points generation, can't figure out why implementation didn't work. although fine original python code.
i've tried adapt demo2 matplotlib surface plot doc mwe:
using pyplot u = linspace(0,2*π,100); v = linspace(0,π,100); x = cos(u).*sin(v); y = sin(u).*sin(v); z = cos(v); surf(x,y,z)
so, what's wrong in julia implementation?
x
, y
, z
should matrices, not vectors -- otherwise have curve drawn on sphere, instead of surface itself.
using pyplot n = 100 u = linspace(0,2*π,n); v = linspace(0,π,n); x = cos(u) * sin(v)'; y = sin(u) * sin(v)'; z = ones(n) * cos(v)'; # rstride , cstride arguments default 10 surf(x,y,z, rstride=4, cstride=4)
the curve drawn corresponds diagonal of matrices.
plot( diag(x), diag(y), diag(z), color="yellow", linewidth=3 )
Comments
Post a Comment