-
-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plotting fails only for specific range #931
Comments
The problem is that Makie uses Float32 a lot internally, as this is what GPUs want. And your values are very close together, which means some algorithm that tries to find steps between your limits finds zero-width range steps. I have just tried this out, out of interest: julia> nfloats(a, b) = begin
n = 0
while true
a = nextfloat(a)
n += 1
a == b && break
end
n
end
julia> a = Float32(1.4030269373737038e6)
1.4030269f6
julia> b = Float32(1.4030269381214702e6)
1.403027f6
julia> nfloats(a, b)
1 So there is just one step from your low to your high value in Float32. There's currently no better solution than to scale your values up in Float64 before plotting. |
Encountered this issue. The workaround works. Suggest better approach to handle this. Thanks. |
I have also run into this error with GLMakie v0.6.3.
A better solution would be good; it's not as if plotting values with a large mean and small variance is an obscure task. |
Aside from the type requirements (e.g. Rect2f, Point2f, Vec2f), is there anything in Makie or MakieCore (not the backends) which relies on values being Float32? If not, I could take a look at making Makie independent of float type, possibly accepting anything which is <: AbstractFloat or Real, then converting them in e.g. |
I don't think there is a need for Float32 types in Makie and MakieCore, but changing those to Float64 doesn't solve the problem. Even if the plot type keeps everything as Float64 you eventually need to convert to Float32 in the GL backends and lose precision. I think what we need to solve this is another step in our conversion pipeline that normalizes data before converting to Float32. Each scene would need an object that keeps track of the total data limits and defines a linear transformation that goes from I played around with the idea a bit before and got a very hacky version working but I don't know how to cleanly implement it in the plotting/conversion pipeline. |
@ffreyer, I know nearly nothing about the internals of makie, but that sounds like a sensible solution. |
Truncating the array to julia> a = [31.999999051331837, 31.99999905020038, 31.99999904907261, 31.999999047948524, 31.99999904682809, 31.99999904571132, 31.999999044598198, 31.999999043488696, 31.999999042382818, 31.999999041280553, 31.99999904018189]
11-element Vector{Float64}:
31.999999051331837
31.99999905020038
31.99999904907261
31.999999047948524
31.99999904682809
31.99999904571132
31.999999044598198
31.999999043488696
31.999999042382818
31.999999041280553
31.99999904018189
julia> Makie.lines(a)
Error showing value of type Makie.FigureAxisPlot:
ERROR: ArgumentError: range step cannot be zero
...
julia> Makie.lines(Float32.(a))
Error showing value of type Makie.FigureAxisPlot:
ERROR: ArgumentError: range step cannot be zero
...
julia> Makie.lines(Float16.(a))
#! It works! Related issues: |
Both @Ceronsand's MWE and my MWE are fixed with GLMakie v0.10.0. |
Steps to reproduce:
ERROR: ArgumentError: range step cannot be zero
Unfortunately i could not yet narrow it down to a reproducible range, error dissapears if something greater than the 6th decimal is changed . Changing the values slightly allows plotting, but the axis doesn't seem aligned properly anymore.
For example:
System Configuration:
Win10, Julia 1.6.1, GLMakie@0.2.8
The text was updated successfully, but these errors were encountered: