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

Colorbar fails with getindex on a poly but not a mesh #1778

Closed
BambOoxX opened this issue Mar 22, 2022 · 2 comments
Closed

Colorbar fails with getindex on a poly but not a mesh #1778

BambOoxX opened this issue Mar 22, 2022 · 2 comments

Comments

@BambOoxX
Copy link

BambOoxX commented Mar 22, 2022

While testing the examples for mesh I stumbled upon a weird error when replacing mesh with poly.

In fact, evaluating this example works fine

using FileIO
using GLMakie

brain = load(assetpath("brain.stl"))

f, ax, m = mesh(
    brain,
    color = [tri[1][2] for tri in brain for i in 1:3],
    colormap = Reverse(:Spectral),
    figure = (resolution = (1000, 1000),)
)

Colorbar(f[1,2],m)

and expectedly returns the brain image with a colorbar on its right
image

However, just replacing the mesh with a poly fails with

ERROR: MethodError: no method matching getindex(::MakieCore.Automatic, ::Int64)
Stacktrace:
  [1] scaled_steps(steps::Vector{Float64}, scale::Function, lims::MakieCore.Automatic)
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables\colorbar.jl:383
  [2] (::Makie.MakieLayout.var"#477#507")(bbox::GeometryBasics.HyperRectangle{2, Float32}, v::Bool, steps::Vector{Float64}, gradient::PlotUtils.ContinuousColorGradient, scale::Function, lims::MakieCore.Automatic)
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables\colorbar.jl:174
  [3] lift(::Function, ::Observable{GeometryBasics.HyperRectangle{2, Float32}}, ::Observable{Any}, ::Vararg{Any}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie D:\bambooxx\.julia\packages\Makie\f11Ut\src\interaction\observables.jl:30
  [4] lift(::Function, ::Observable{GeometryBasics.HyperRectangle{2, Float32}}, ::Observable{Any}, ::Observable{Vector{Float64}}, ::Vararg{Any})
    @ Makie D:\bambooxx\.julia\packages\Makie\f11Ut\src\interaction\observables.jl:27
  [5] layoutable(::Type{Colorbar}, fig_or_scene::Figure; bbox::Nothing, kwargs::Base.Pairs{Symbol, Observable{Any}, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :limits), Tuple{Observable{Any}, Observable{Any}}}})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables\colorbar.jl:169
  [6] layoutable(::Type{Colorbar}, fig_or_scene::Figure, plot::Combined{Makie.poly, Tuple{GeometryBasics.Mesh{3, Float32, GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.FaceView{GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, StructArrays.StructVector{GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, NamedTuple{(:position, :normals), Tuple{Vector{Point{3, Float32}}, Vector{Vec{3, Float32}}}}, Int64}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables\colorbar.jl:9
  [7] layoutable
    @ D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables\colorbar.jl:3 [inlined]
  [8] #_layoutable#11
    @ D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:69 [inlined]
  [9] _layoutable
    @ D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:69 [inlined]
 [10] _layoutable(T::Type{Colorbar}, gp::GridPosition, args::Combined{Makie.poly, Tuple{GeometryBasics.Mesh{3, Float32, GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.FaceView{GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, StructArrays.StructVector{GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, NamedTuple{(:position, :normals), Tuple{Vector{Point{3, Float32}}, Vector{Vec{3, Float32}}}}, Int64}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:64
 [11] _layoutable(T::Type{Colorbar}, gp::GridPosition, args::Combined{Makie.poly, Tuple{GeometryBasics.Mesh{3, Float32, GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.FaceView{GeometryBasics.TriangleP{3, Float32, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}}, GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, StructArrays.StructVector{GeometryBasics.PointMeta{3, Float32, Point{3, Float32}, (:normals,), Tuple{Vec{3, Float32}}}, NamedTuple{(:position, :normals), Tuple{Vector{Point{3, Float32}}, Vector{Vec{3, Float32}}}}, Int64}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}}})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:60
 [12] Colorbar(::GridPosition, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:49
 [13] Colorbar(::GridPosition, ::Vararg{Any})
    @ Makie.MakieLayout D:\bambooxx\.julia\packages\Makie\f11Ut\src\makielayout\layoutables.jl:49
 [14] top-level scope
    @ REPL[30]:1

Apparently doing the same thing with wireframe fails in the same fashion.
This is particularly surprising to me since a mesh seems to be the combination of a poly and a wireframe...

I'm running on

Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, tigerlake)

with GLMakie v0.5.1

@BambOoxX
Copy link
Author

Additional information:

  • The problem stiil show up with latest GLMakie version : v0.6.8
  • If a colorrange argument is passed, the error does no show up, making it linked with the MakieCore.Automatic not being handled at some point.

@ffreyer
Copy link
Collaborator

ffreyer commented Aug 23, 2024

This was fixed

@ffreyer ffreyer closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants