Skip to content
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

cannot mix colormaps with DataInspector #3319

Closed
MariusDrulea opened this issue Oct 27, 2023 · 8 comments
Closed

cannot mix colormaps with DataInspector #3319

MariusDrulea opened this issue Oct 27, 2023 · 8 comments
Labels

Comments

@MariusDrulea
Copy link
Contributor

using GLMakie
using ColorTypes

fig = Figure()
image(fig[1, 1], Gray.(rand(100, 100)), axis=(yreversed=true,), interpolate=false, colormap=:viridis)
DataInspector(fig)
fig

This code ignores the colormap attribute and show a gray level image. DataInspector works here.
image

using GLMakie
using ColorTypes

fig = Figure()
image(fig[1, 1], rand(10, 10), axis=(yreversed=true,), interpolate=false, colormap=:viridis)
DataInspector(fig)
fig

This code shows a nicely colored image, but on hovering over the image the DataInspector crashes with the following error.
image

Error in callback:
MethodError: no method matching interpolated_getindex(::Vector{RGBA{Float32}}, ::Float32, ::MakieCore.Automatic)

Closest candidates are:
  interpolated_getindex(::AbstractArray{T}, ::AbstractFloat) where T
   @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\colorsampler.jl:46
  interpolated_getindex(::AbstractArray, ::Number, ::Union{Tuple{Vararg{T, N}}, StaticArray{Tuple{N}, T, 1}} where {N, T})
   @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\colorsampler.jl:34

Stacktrace:
  [1] show_imagelike(inspector::DataInspector, plot::Image{Tuple{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}, Matrix{Float32}}}, name::String, edge_based::Bool)
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:663
  [2] show_data
    @ D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:624 [inlined]
  [3] show_data_recursion(inspector::DataInspector, plot::Image{Tuple{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}, Matrix{Float32}}}, idx::UInt32)      
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:339
  [4] on_hover(inspector::DataInspector)
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:307
  [5] (::Makie.var"#1152#1156"{DataInspector})(#unused#::Tuple{Float64, Float64})
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:280
@MariusDrulea MariusDrulea changed the title cannot mix colormaps with DataInpector cannot mix colormaps with DataInspector Oct 27, 2023
@SimonDanisch
Copy link
Member

Can you try master? I think this is fixed!

@MariusDrulea
Copy link
Contributor Author

MariusDrulea commented Oct 27, 2023

I just tried master and I get the same behavior on both of the scenarios above.

@SimonDanisch
Copy link
Member

Ah sorry, I mixed up your issues.
This is expected, although we could throw an error... Related #2966
If your array is already mapped to colors, it can't be mapped via a colormap!

@MariusDrulea
Copy link
Contributor Author

Ok, I can extract extract the raw values from Gray such that colormap works. But then DataInspector is expected to show that raw value. Do you agree?

@SimonDanisch
Copy link
Member

Yeah, does it on master?

@MariusDrulea
Copy link
Contributor Author

Nope, also on master DataInspector crashes:

using GLMakie
fig, = image(rand(10, 10), axis=(yreversed=true,), interpolate=false, colormap=:viridis)
DataInspector(fig)
fig
Error in callback:
MethodError: no method matching interpolated_getindex(::Vector{RGBA{Float32}}, ::Float32, ::MakieCore.Automatic)

Closest candidates are:
  interpolated_getindex(::AbstractArray{T}, ::AbstractFloat) where T
   @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\colorsampler.jl:46
  interpolated_getindex(::AbstractArray, ::Number, ::Union{Tuple{Vararg{T, N}}, StaticArray{Tuple{N}, T, 1}} where {N, T})
   @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\colorsampler.jl:34

Stacktrace:
  [1] show_imagelike(inspector::DataInspector, plot::Image{Tuple{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}, Matrix{Float32}}}, name::String, edge_based::Bool)
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:663
  [2] show_data
    @ D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:624 [inlined]
  [3] show_data_recursion(inspector::DataInspector, plot::Image{Tuple{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}, Matrix{Float32}}}, idx::UInt32)      
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:339
  [4] on_hover(inspector::DataInspector)
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:307
  [5] (::Makie.var"#1152#1156"{DataInspector})(#unused#::Tuple{Float64, Float64})
    @ Makie D:\z_installed_programs\julia-depot\packages\Makie\NrrbP\src\interaction\inspector.jl:280

@MariusDrulea
Copy link
Contributor Author

MariusDrulea commented Oct 27, 2023

What I did:

pkg> add GLMakie#master

Shall I also add Makie to master, beside GLMakie? I don't have Makie as explicit dependency, only GLMakie.

@MariusDrulea
Copy link
Contributor Author

I have set both Makie and GLMakie to "master" and now it works indeed:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants