# Hide stroke in 3D scatter using Makie.jl

**URL:** <https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383>\
**Category:** Visualization\
**Tags:** question, plotting, makie\
**Created:** [November 17, 2023, 6:15pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383 "2023-11-17T18:15:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [November 17, 2023, 6:15pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/1 "2023-11-17T18:15:18Z")

</div>

Compare the two scatter plots produced by GLMakie in 2D and 3D:

```julia
scatter(rand(1000), rand(1000))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/1/81bad05c358bb2a5f3621ca52a9c8599ff4407a6.png)

```julia
scatter(rand(1000), rand(1000), rand(1000))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/5/9/59cec77aff8ca6073b8d70382add325e99f6e4e2.png)

Is there an option to hide the white stroke around the dots in 3D? When the cloud of points is very dense these strokes end up hiding the actual colors of the dots.

I tried playing with `strokewidth`, `strokecolor`, `glowwidth`, `glowcolor`, … but none of these options change the plot in 3D.

---

<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:** [November 17, 2023, 6:28pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/2 "2023-11-17T18:28:39Z")

</div>

They are not strokes, they are rendering artifacts of the antialiasing. When a dot in front gets a half-transparent edge mixed with white background then it can block dots from behind that are rendered later from showing through. I’ve always wondered if that can be avoided, maybe @sdanisch or @ffreyer know

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [November 17, 2023, 7:18pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/3 "2023-11-17T19:18:36Z")

</div>

Thank you @jules, I imagined it was something like that. It would be nice to be able to hide these side effects.

---

<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:** [November 17, 2023, 7:32pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/4 "2023-11-17T19:32:25Z")

</div>

You can trade this problem for incorrect render order with `overdraw = true` or for some amount of transparency with `transparency = true`.

We could look into drawing markers without anti-aliasing and use fxaa to approximate it later. This might be pretty bad if things get small though, i.e. with text, thin stroke, thin linewidths (lines has the same problem) or very small markers. So it would need to be an adjustable option.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [November 17, 2023, 7:42pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/5 "2023-11-17T19:42:40Z")

</div>

Thank you @ffreyer,`overdraw=true` solves the problem.

---

<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:** [December 21, 2023, 4:00pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/6 "2023-12-21T16:00:49Z")

</div>

I worked on two more ways to treat this problem in GLMakie, which now got merged and will be available in Makie 0.20.3+. There is also a new subsection about this in the scatter docs: [scatter · Makie](https://docs.makie.org/stable/reference/plots/scatter/#dealing_with_outline_artifacts_in_glmakie)

To summarize the new features:

- Setting `fxaa = true` now replaces the native anti-aliasing with fxaa, which degrades marker quality but entirely removes the edge artifacts. Good if big markers without fine lines.
- Setting `depthsorting = true` results in markers being sorted on the CPU side before rendering. This removes the problem between markers of the same `scatter` call without degrading quality, but doesn’t find the problem when other objects are involved. (Plot order may help here)

---

<div class="post-metadata">

**Author:** ![barnett567](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@barnett567](https://discourse.julialang.org/u/barnett567)\
**Post date:** [February 21, 2024, 10:31pm UTC](https://discourse.julialang.org/t/hide-stroke-in-3d-scatter-using-makie-jl/106383/7 "2024-02-21T22:31:42Z")

</div>

Wonderful - I tried these options and they are super useful to professionalize my scatter plots. Thanks!
