MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.42k stars 313 forks source link

DataInspector looks up wrong elements and hits bounds error #3287

Open GlenHertz opened 1 year ago

GlenHertz commented 1 year ago

I'm calling recipes like so:

measuresignals!(ax_measuresignals, signal; color, linewidth=2, inspectable, label) # with `lines!(plt, xs, ys; inspectable=false)`  
measuresignals!(ax_measuresignals, ms; colors_for_signals) # with `scattter!(plt, xs, ys; inspector_label)`
DataInspector(ax_measuresignals)

But then I get the following DataInspector errors when mousing over the lines (not the scatter!):

┌ Warning: Error in window event callback
│   exception =
│    BoundsError: attempt to access 5000-element Vector{GeometryBasics.Point{2, Float32}} at index [45824]
│    Stacktrace:
│      [1] getindex(A::Vector{GeometryBasics.Point{2, Float32}}, i1::Int64)
│        @ Base ./essentials.jl:13
│      [2] position_on_plot(plot::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}, idx::Int64, ray::Makie.Ray; apply_transform::Bool)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/ray_casting.jl:243
│      [3] position_on_plot(plot::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}, idx::Int64; apply_transform::Bool)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/ray_casting.jl:235
│      [4] position_on_plot(plot::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}, idx::Int64)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/ray_casting.jl:234 [inlined]
│      [5] show_data(inspector::Makie.DataInspector, plot::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}, idx::Int64)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/inspector.jl:425
│      [6] show_data_recursion(inspector::Makie.DataInspector, plot::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}, idx::Int64)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/inspector.jl:339
│      [7] on_hover(inspector::Makie.DataInspector)
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/inspector.jl:307
│      [8] (::Makie.var"#1084#1088"{Makie.DataInspector})(::Tuple{Float64, Float64})
│        @ Makie ~/.julia/packages/Makie/x0YXS/src/interaction/inspector.jl:280
│      [9] invokelatest(f::Any, args::Any; kwargs::@Kwargs{})
│        @ Base ./essentials.jl:887 [inlined]
│     [10] invokelatest(f::Any, args::Any)
│        @ Base ./essentials.jl:884 [inlined]
│     [11] notify(observable::Observables.Observable)
│        @ Observables ~/.julia/packages/Observables/PHGQ8/src/Observables.jl:169 [inlined]
│     [12] setindex!(observable::Observables.Observable, val::Any)
│        @ Observables ~/.julia/packages/Observables/PHGQ8/src/Observables.jl:86
│     [13] (::WGLMakie.var"#57#59"{Dict{Any, Any}, Makie.Scene, Makie.Events})()
│        @ WGLMakie ~/.julia/packages/WGLMakie/YrLHQ/src/events.jl:57
└ @ WGLMakie ~/.julia/packages/WGLMakie/YrLHQ/src/events.jl:109
julia> 

The scatter has 5000 points while lines has many more so it seems that the data inspector is looking up the data inspector on lines but calling the scatter inspector.

I'll experiment a bit to try to track this down further.

ffreyer commented 1 year ago

It would be good to have a MWE for this and to check if this also errors with GLMakie.

ffreyer commented 2 months ago

Is this still an issue?