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

Legend not working when using custom colorrange #3532

Closed
3 tasks done
howbgl opened this issue Jan 5, 2024 · 0 comments · Fixed by #3587
Closed
3 tasks done

Legend not working when using custom colorrange #3532

howbgl opened this issue Jan 5, 2024 · 0 comments · Fixed by #3587
Assignees
Labels

Comments

@howbgl
Copy link

howbgl commented Jan 5, 2024

  • are you running newest version (version from docs) ? Makie v0.20.4 & CairoMakie v0.11.5
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on?
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × AMD Ryzen 5 5625U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
  Threads: 1 on 12 virtual cores

MWE

using CairoMakie

f = Figure()
ax = Axis(f[1,1])
for i in 1:8
    lines!(ax,rand(16);colorrange=(1,8),color=i,label="$i")
end
axislegend(ax)

Similar results occur when using scatter! instead of lines! and f[1, 2] = Legend(f, ax, "Legend") instead of the call to axislegend.

The latest version where the MWE is not broken is Makie v0.19.5 and CairoMakie v0.10.6.

Stacktrace

ERROR: Cannot determine a colorrange automatically for single number color value. Pass an explicit colorrange.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] assemble_colors(::Int64, color::Observable{Any}, plot::Lines{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/colorsampler.jl:364
  [3] color_and_colormap!(plot::Lines{Tuple{Vector{Point{2, Float32}}}}, colors::Observable{Any})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/interfaces.jl:14
  [4] color_and_colormap!(plot::Lines{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/interfaces.jl:10
  [5] calculated_attributes!
    @ Makie ~/.julia/packages/Makie/fyNiH/src/interfaces.jl:98 [inlined]
  [6] connect_plot!(parent::Scene, plot::Lines{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/interfaces.jl:253
  [7] plot!(scene::Scene, plot::Lines{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/interfaces.jl:260
  [8] _create_plot!(F::Function, attributes::Dict{Symbol, Any}, scene::Scene, args::Observable{Vector{Point{2, Float32}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/figureplotting.jl:265
  [9] lines!(::Scene, ::Vararg{…}; kw::@Kwargs{})
    @ MakieCore ~/.julia/packages/MakieCore/5nuEY/src/recipes.jl:176
 [10] legendelement_plots!(scene::Scene, element::LineElement, bbox::Observable{…}, defaultattrs::Attributes)
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:286
 [11] (::Makie.var"#2010#2024"{})(entry_groups::Vector{…})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:229
 [12] #invokelatest#2
    @ ./essentials.jl:887 [inlined]
 [13] invokelatest
    @ ./essentials.jl:884 [inlined]
 [14] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [15] initialize_block!(leg::Legend; entrygroups::Observable{Vector{Tuple{Nothing, Vector{LegendEntry}}}})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:247
 [16] _block(T::Type{…}, fig_or_scene::Figure, args::Tuple{}, kwdict::Dict{…}, bbox::Observable{…}; kwdict_complete::Bool)
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks.jl:388
 [17] Legend(fig_or_scene::Figure, contents::Vector{…}, labels::Vector{…}, title::Nothing; bbox::Observable{…}, kwargs::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:514
 [18] Legend(fig_or_scene::Figure, axis::Axis, title::Nothing; merge::Bool, unique::Bool, kwargs::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:562
 [19] Legend
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:559 [inlined]
 [20] #axislegend#2069
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:627 [inlined]
 [21] axislegend
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:626 [inlined]
 [22] axislegend(ax::Axis)
    @ Makie ~/.julia/packages/Makie/fyNiH/src/makielayout/blocks/legend.jl:603
 [23] top-level scope
    @ REPL[47]:1
@howbgl howbgl added the bug label Jan 5, 2024
@t-bltg t-bltg mentioned this issue Jan 7, 2024
7 tasks
@t-bltg t-bltg self-assigned this Jan 7, 2024
@jkrumbiegel jkrumbiegel linked a pull request Feb 1, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants