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 tickformat cannot be specified when the colormap is Categorical #4597

Open
barucden opened this issue Nov 18, 2024 · 1 comment
Open
Labels

Comments

@barucden
Copy link
Contributor

Makie version: Makie v0.21.16

I can reproduce the bug in a fresh environment.

I am using CairoMakie without GPU. My Julia version is

Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

A MWE is:

f = Figure()
a = Axis(f[1, 1])
hm = heatmap!(a, rand(1:10, 10, 10), colormap=Makie.Categorical(:inferno))
Colorbar(f[1, 2], hm, tickformat="1")

The colorbar line results in

ERROR: MethodError: Cannot `convert` an object of type Tuple{UnitRange{Int64}, Vector{String}} to an object of type Vector{Float64}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  convert(::Type{Array{T, N}}, ::StaticArraysCore.SizedArray{S, T, N, N, Array{T, N}}) where {S, T, N}
   @ StaticArrays ~/.julia/packages/StaticArrays/9Yt0H/src/SizedArray.jl:88
  convert(::Type{Array{T, N}}, ::StaticArraysCore.SizedArray{S, T, N, M, TData} where {M, TData<:AbstractArray{T, M}}) where {T, S, N}
   @ StaticArrays ~/.julia/packages/StaticArrays/9Yt0H/src/SizedArray.jl:82
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:126
  ...

Stacktrace:
  [1] get_tickvalues(tickvalues::Tuple{UnitRange{Int64}, Vector{String}}, vmin::Float64, vmax::Float64)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:631
  [2] get_tickvalues(ticks::Tuple{UnitRange{Int64}, Vector{String}}, ::Function, vmin::Float64, vmax::Float64)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:566
  [3] get_ticks(ticks::Tuple{UnitRange{…}, Vector{…}}, scale::Function, formatter::String, vmin::Float64, vmax::Float64)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:554
  [4] get_ticks(::Nothing, ticks::Tuple{…}, scale::Function, formatter::String, vmin::Float64, vmax::Float64)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/dim-converts/dim-converts.jl:70
  [5] (::Makie.var"#1611#1625"{…})(::Tuple{…}, ::Nothing, limits::Tuple{…}, ticks::Tuple{…}, tickformat::String, scale::Function)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:423
  [6] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:1055
  [7] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:1052
  [8] (::Observables.MapCallback)(value::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:436
  [9] #map!#238
    @ ~/.julia/packages/Makie/pFPBw/src/scenes.jl:170 [inlined]
 [10] map!
    @ ~/.julia/packages/Makie/pFPBw/src/scenes.jl:163 [inlined]
 [11] Makie.LineAxis(parent::Scene, attrs::Attributes)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:421
 [12] #LineAxis#1587
    @ ~/.julia/packages/Makie/pFPBw/src/makielayout/lineaxis.jl:8 [inlined]
 [13] initialize_block!(cb::Colorbar)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks/colorbar.jl:362
 [14] _block(T::Type{…}, fig_or_scene::Figure, args::Vector{…}, kwdict::Dict{…}, bbox::Nothing; kwdict_complete::Bool)
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:371
 [15] _block
    @ ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:291 [inlined]
 [16] #_block#1436
    @ ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:259 [inlined]
 [17] _block(::Type{Colorbar}, ::GridPosition; kwargs::@Kwargs{colormap::Makie.ColorMapping{…}, tickformat::String})
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:253
 [18] _block
    @ ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:246 [inlined]
 [19] #_#1434
    @ ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks.jl:237 [inlined]
 [20] Colorbar(fig_or_scene::GridPosition, plot::Heatmap{Tuple{…}}; kwargs::@Kwargs{tickformat::String})
    @ Makie ~/.julia/packages/Makie/pFPBw/src/makielayout/blocks/colorbar.jl:108
 [21] top-level scope
    @ REPL[20]:1

Changing the colormap to (continuous) :inferno makes the error go away, and so does removing the tickformat argument.

@barucden barucden added the bug label Nov 18, 2024
@barucden
Copy link
Contributor Author

Related to #3686

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

1 participant