Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

julia

makie.jl

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?

like image 425
aquaticapetheory Avatar asked Nov 08 '21 19:11

aquaticapetheory


1 Answers

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.

like image 184
Frederic Freyer Avatar answered Oct 27 '22 15:10

Frederic Freyer