4

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

François Févotte
  • 19,520
  • 4
  • 51
  • 74
Tom
  • 100
  • 6
  • As an alternative, there are a couple of examples using Gaston.jl here: https://mbaz.github.io/Gaston.jl/stable/3d-gallery/#Spheres-1 – MBaz Oct 04 '20 at 15:41

2 Answers2

3

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

François Févotte
  • 19,520
  • 4
  • 51
  • 74
  • Looks great! Do you know why the plot isn't working in **nteract**? I tried your example but I get no plot result, everything else works fine. Also no error. – Tom Oct 04 '20 at 13:36
  • **Print:** Scene (1920px, 1080px): 2 Plots: ├ Axis3D{...} └ MeshScatter{...} 0 Child Scenes – Tom Oct 04 '20 at 13:46
  • Might be because nteract does not know how to display the resulting scene. A workaround to that would be to save the generated scene as an image, and display the image instead. – François Févotte Oct 04 '20 at 14:11
2

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

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62