Search code examples
juliamakie.jl

Quantization distortion in x-axis of GLMakie plot. Why?


I create a simple plot using GLMakie:

GLMakie.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )

The result looks like this:

enter image description here

Looks like the x-axis is heavily quantized. The Plots package handles the same command just fine:

Plots.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )

enter image description here

GLMakie can also handle the same plot if the x range is centered on 0:

GLMakie.scatter( range((-5e-9)..(5e-9),100), range(1..100,100) )

enter image description here

Why is this happening? Does GLMakie use a smaller float for speed? Can I do anything to avoid this?


Solution

  • Does GLMakie use a smaller float for speed?

    Yes it does. OpenGL commonly uses 32 bit floats and Makie has been built with Float32 as a result. Right now you'd have normalize your data and adjust ticks manually to fix this. See https://makie.juliaplots.org/stable/examples/layoutables/axis/index.html#modifying_ticks

    There are also a bunch of issues regarding this on github, for example https://github.com/JuliaPlots/Makie.jl/issues/1373.