# Poor Mesh Plot from Makie - How to fix it?

**URL:** <https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064>\
**Category:** New to Julia\
**Tags:** makie\
**Created:** [March 2, 2024, 3:46pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064 "2024-03-02T15:46:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Midez](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Midez](https://discourse.julialang.org/u/Midez)\
**Post date:** [March 2, 2024, 3:46pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/1 "2024-03-02T15:46:43Z")

</div>

Minimal example with a dummy mesh

```julia
using Makie, GLMakie, FileIO

msh = load("~/TestMesh.stl")

fig = Figure(resolution = (1920,1080))

axe = Axis3(fig[1, 1])

mesh!(msh, transparency = false, overdraw = false, shading = true)

wireframe!(msh, color = :red, transparency = true, overdraw = false)

hidedecorations!(axe)

display(fig)

```

What I get is the following

 ![PoorMesh](https://global.discourse-cdn.com/julialang/original/3X/d/7/d73eed87f53db39b71fc5dc8d9fe7c2403442f91.jpeg)

Here some weird artifacts are visible.

* * *

Actually what I want is similar to the generated file with this Matlab-Code

```julia
P = stlread('~/TestMesh.stl');

trimesh(P,'EdgeColor','r')

hold on

trisurf(P,'EdgeColor','none','FaceColor','c')

axis off

lightangle(-45,30)

lighting gouraud

```

 ![NiceMesh](https://global.discourse-cdn.com/julialang/original/3X/3/4/34531f1dfabc3188bad28eed27f4cc0c858a9718.png)

Here the geometry is drawn nicely.

So can this style be adapted in Makie?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 2, 2024, 5:18pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/2 "2024-03-02T17:18:35Z")

</div>

Is TestMesh.stl available somewhere?

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [March 2, 2024, 6:32pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/3 "2024-03-02T18:32:06Z")

</div>

Set `color` for the mesh plot to something opaque. The default has some transparency

---

<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:** [March 2, 2024, 8:11pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/4 "2024-03-02T20:11:23Z")

</div>

That default was only meant for 2d shapes overlapping. We should think about changing it for meshes, in 3D transparency has a couple problems

---

<div class="post-metadata">

**Author:** ![Midez](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Midez](https://discourse.julialang.org/u/Midez)\
**Post date:** [March 2, 2024, 9:12pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/5 "2024-03-02T21:12:39Z")

</div>

Just for your interest - here is the file I’m Testing with

- [TU Berlin](https://tubcloud.tu-berlin.de/s/98DSZ4r8XcQexw2)

---

<div class="post-metadata">

**Author:** ![Midez](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Midez](https://discourse.julialang.org/u/Midez)\
**Post date:** [March 2, 2024, 9:13pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/6 "2024-03-02T21:13:56Z")

</div>

Aw, thats’s unfortunate. But big up for your work so far!

---

<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:** [March 3, 2024, 1:07pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/7 "2024-03-03T13:07:42Z")

</div>

With an opaque cyan and black lines it’s much closer to your matlab example, although the default light doesn’t come from the front anymore:

```julia
mesh!(msh, transparency = false, overdraw = false, color = :cyan)

wireframe!(msh, color = :black, linewidth = 0.5)

hidedecorations!(axe)

fig

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/1/51047ca23d26caeba80531d8ebd912ac77772740.png)

And if the directional light comes from the front it looks even closer:

```julia
fig = Figure()

axe = Axis3(fig[1, 1])
axe.scene.lights[2].direction[] = Vec3f(0, 0, -1)

mesh!(msh, transparency = false, overdraw = false, color = :cyan)

wireframe!(msh, color = :black, linewidth = 0.5)

hidedecorations!(axe)

fig

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/5/8558fb848b60693507b4b2498cb030a65eab2ff1.png)

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [March 3, 2024, 1:10pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/8 "2024-03-03T13:10:52Z")

</div>

It seems that Matlab’s mesh lines are much sharper, though.

---

<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:** [March 3, 2024, 1:20pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/9 "2024-03-03T13:20:58Z")

</div>

with `fxaa = true` on the wireframe it seems a bit better, but I still sometimes think our problem is that we draw the lines in a separate pass than the mesh. I assume matlab does it in one go

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/9/29d9672aa1f0364df4efff3a48d3883f74140f99.png)

---

<div class="post-metadata">

**Author:** ![Midez](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Midez](https://discourse.julialang.org/u/Midez)\
**Post date:** [March 3, 2024, 7:10pm UTC](https://discourse.julialang.org/t/poor-mesh-plot-from-makie-how-to-fix-it/111064/10 "2024-03-03T19:10:32Z")

</div>

awesome, this is still looking really nice and is exactly what I want! Thx
