Hi all,
I want to create 3-dimensional torus like this:
With GLMakie or Plots, because I want to add annotations, and then I can see which is x,y,z axis
I get the code from Lazarus’ website
using Gnuplot
let
U = LinRange(-π,π, 50)
V = LinRange(-π,π, 30)
r = 0.5
x = [1 + cos(u) + r * cos(u) * cos(v) for u in U, v in V]
y = [r * sin(v) for u in U, v in V]
z = [sin(u) + r * sin(u) * cos(v) for u in U, v in V]
@gsp "set pm3d depthorder"
@gsp :- "set style fill transparent solid 0.5"
@gsp :- "set pm3d lighting primary 0.05 specular 0.2"
@gsp :- x y z "w l palette notit" palette(:dense) "set view 108,2"
@gsp :- "unset border" "set xyplane 0"
@gsp :- "unset tics"
@gsp :- "unset colorbox"
end
with gnuplot it has a lot of lines, maybe because my eyes are used to Plots and gr().
I have more questions about 3-d plots in the future. Thanks for all your help here.
Edited:
I have the GLMakie code thanks to this topic:
My question on this GLMakie, how to add the label to x,y,z axis?
using GLMakie
using ColorSchemes
cmap3 = get(colorschemes[:plasma], LinRange(0,1,100))
cmap4 = [(cmap3[i],0.65) for i in 1:100]
ξ = -40:1:40
c = 20
a = 15
torus = [((hypot(X,Y)-c)^2+Z^2-a^2) for X in ξ, Y in ξ, Z in ξ]
volume(torus, algorithm = :iso,isovalue =100,isorange =50, colormap=cmap4)
current_figure()
why GLMakie plot of torus has a glitch? like small black hole around the torus?