# Aliasing with Makie contourf

**URL:** <https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [November 19, 2021, 2:59pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783 "2021-11-19T14:59:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smillerc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/smillerc/32/35457_2.png) [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Post date:** [November 19, 2021, 2:59pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783/1 "2021-11-19T14:59:43Z")

</div>

Is there a way to get rid of the aliasing in the `contourf!` lines in the following example?

```julia
using CairoMakie

function testcontourf()
    xs = LinRange(0, 10, 100)
    ys = LinRange(0, 10, 100)
    zs = [cos(x) * sin(y) for x in xs, y in ys]

    f = Figure()
    ax = Axis(f[1, 1])

    c = contourf!(ax, xs, ys, zs, levels = 50)
    Colorbar(f[1, 2], c)
    display(f)
end

testcontourf()

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/2/6206bd651b5230b30cc0b09acc9524bb9f2535d6.jpeg)

In actuality, I’d prefer to get the plot to look the way it does if I double the `contourf!` call, and eliminated the lines that show up.

```julia
function testcontourf_double()
    xs = LinRange(0, 10, 100)
    ys = LinRange(0, 10, 100)
    zs = [cos(x) * sin(y) for x in xs, y in ys]

    f = Figure()
    ax = Axis(f[1, 1])

    c = contourf!(ax, xs, ys, zs, levels = 50)
    c = contourf!(ax, xs, ys, zs, levels = 50)
    Colorbar(f[1, 2], c)
    
    display(f)
end

testcontourf_double()

```

Which results in this image without the lines.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/9/39a27f76e0e009ac31cbf51abc3f1ba4658a56dd.jpeg)

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [November 19, 2021, 3:09pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783/2 "2021-11-19T15:09:46Z")

</div>

So, you maybe just want a heatmap? there is also the option of `interpolate=true`, to get smooth interpolation between data points

---

<div class="post-metadata">

**Author:** ![smillerc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/smillerc/32/35457_2.png) [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Post date:** [November 19, 2021, 3:24pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783/3 "2021-11-19T15:24:32Z")

</div>

Neat, I didn’t know about the interpolate option for `heatmap!`. That helps. I’m guessing the lines are just a result of the way Makie plots each level?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [November 19, 2021, 3:32pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783/4 "2021-11-19T15:32:11Z")

</div>

Well, if you plot lines too closely together they will alias… You would need some global anti aliasing pre-processing filter on top of that, which usually isn’t used in e.g. CairoMakie, which aliases each object (e.g. the lines) separately for optimal quality.

A global aliasing filter is usually not preferred if possible, since it has much less information and introduces new artifacts that way.

---

<div class="post-metadata">

**Author:** ![smillerc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/smillerc/32/35457_2.png) [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Post date:** [November 19, 2021, 3:33pm UTC](https://discourse.julialang.org/t/aliasing-with-makie-contourf/71783/5 "2021-11-19T15:33:36Z")

</div>

Ok, that makes sense. Either way, thanks for your work on Makie! It’s my go-to plotting library in julia
