How to plot spheres with Julia?

1.1k views Asked by At

Simple Problem, I have a data set with x-,y-,z-coordinates and the volume of each sphere. Should be enough data to plot these spheres? Isn't it?

I'm new to Julia and I actually have no clue how to do this. Couldn't find any similar and helpful answer...

Thank you, Tom

Should look like that

2

There are 2 answers

3
François Févotte On BEST ANSWER

I think Makie would be a good option. The documentation for meshscatter gives an example that can be adapted to better fit what you'd like to achieve:

using Makie

x = 100*rand(10)
y = 100*rand(10)
z = 100*rand(10)
scene = meshscatter(x, y, z, markersize = 10, color = :white)
Makie.save("plot.png", scene)

enter image description here

1
Przemyslaw Szufel On

Another option is PyPlot:

using PyPlot

N = 32
u = range(0, stop=2π, length=N)
v = range(0, stop=π, length=N)
x = cos.(u) .* sin.(v)'
y = sin.(u) .* sin.(v)'
z = repeat(cos.(v)',outer=[N, 1])
PyPlot.surf(x,y,z)
PyPlot.savefig("plot.png")

enter image description here