# Precipitates in a 3D matrix

**URL:** <https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002>\
**Category:** New to Julia\
**Tags:** makie, 3d\
**Created:** [September 1, 2025, 7:52am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002 "2025-09-01T07:52:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ES\_VI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/es_vi/32/218488_2.png) [@ES\_VI](https://discourse.julialang.org/u/ES_VI)\
**Post date:** [September 1, 2025, 7:52am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/1 "2025-09-01T07:52:43Z")

</div>

![ni_ppt.jpeg](https://global.discourse-cdn.com/julialang/original/3X/e/b/ebc34d744ee014a3226fa3dbb89b509b03ad2767.png)  
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.

---

<div class="post-metadata">

**Author:** ![sablonl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sablonl/32/217805_2.png) [@sablonl](https://discourse.julialang.org/u/sablonl)\
**Post date:** [September 1, 2025, 8:40am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/2 "2025-09-01T08:40:51Z")

</div>

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

```julia
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](https://docs.makie.org/dev/reference/blocks/axis3)).

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [September 1, 2025, 9:01am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/3 "2025-09-01T09:01:01Z")

</div>

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

> **[meshscatter | Makie](https://docs.makie.org/stable/reference/plots/meshscatter)**
>
> Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and...

---

<div class="post-metadata">

**Author:** ![Boris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris/32/3306_2.png) [@Boris](https://discourse.julialang.org/u/Boris)\
**Post date:** [September 1, 2025, 11:58am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/4 "2025-09-01T11:58:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ES\_VI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/es_vi/32/218488_2.png) [@ES\_VI](https://discourse.julialang.org/u/ES_VI)\
**Post date:** [September 2, 2025, 5:09am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/5 "2025-09-02T05:09:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ES\_VI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/es_vi/32/218488_2.png) [@ES\_VI](https://discourse.julialang.org/u/ES_VI)\
**Post date:** [September 2, 2025, 5:11am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/6 "2025-09-02T05:11:24Z")

</div>

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

 ![precipitate_plot](https://global.discourse-cdn.com/julialang/original/3X/6/7/675e44a976f7cf33aa3d1b692f8fdd91b06922d5.png)

---

<div class="post-metadata">

**Author:** ![ES\_VI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/es_vi/32/218488_2.png) [@ES\_VI](https://discourse.julialang.org/u/ES_VI)\
**Post date:** [September 2, 2025, 5:15am UTC](https://discourse.julialang.org/t/precipitates-in-a-3d-matrix/132002/7 "2025-09-02T05:15:56Z")

</div>

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.
