Precipitates in a 3D matrix


Hi Everyone!

I am trying to plot my data (4 columns x,y,z,composition) which when plotted in MATLAB looks like the figure attached. I tried other opensource tools like GNUPLOT and Octave. But those show the precipitates like flat circles. I want makie to shine light so that the data points in each precipitate (blue spheres) look 3D.

I have something similar somewhere, here is a simple adaptation that could fit your need:

using CairoMakie
CairoMakie.activate!()

x, y, z = eachcol(rand(50, 3))

fig = Figure(size = (800, 600))
ax = Axis3(fig[1, 1],
	xlabel = "X",
	ylabel = "Y",
	zlabel = "Z",
	title = "3D Spheres with Lighting",
	aspect = :data,
	perspectiveness = 0.5f0,
	azimuth = π / 4,
	elevation = π / 6,
)

for (xi, yi, zi) in zip(x, y, z)
    sphere = Sphere(Point3f(xi, yi, zi), 0.05f0)
    mesh!(ax, sphere,
        color = :steelblue,
        shading = true,
        shininess = 32f0,
        diffuse = 0.8f0,
        specular = 0.4f0,
    )
end

display(fig)

I guess you could start with this and play with the different keywords and option to enhance the visual quality (Axis3 | Makie).

1 Like

Doing mesh in a loop will be slow for all but a small number of points, this is the prime use case for meshscatter:

4 Likes

I cannot help with code but as a user, the image above is very uninformative.

3D graphs are in general hard to read. Consider adding a color for the depth or better yet, try to not have a 3D graph. This comes from a person who has extensive use of surface and mesh in Matlab. In almost all cases I could plot the data differently.

1 Like

Thank you Sablonl. Your suggestion worked Here is the output. It has that 3D effect (lighting and shadow) too.

Thank you jules. your suggestion worked. I used meshscatter and GLMakie in my script.

Hi Boris. Visualizing precipitates in 3D is of importance in materials science. We plot the quantitative information like the average radius or the radius distribution in 2D. so we use both. naturally 2D is easier to plot.