Skip to content

Legend toggle errors with vlines #5520

@TomRottier

Description

@TomRottier

It would be nice to be able to toggle the visibility of lines created with vlines in the legend the same way you can with other lines, but currently it seems you can't:

using GLMakie
vlines([0, 1]; label="a")
axislegend(; position=:cc)

and clicking on the plot in the legend gives the stack trace:

Cannot attach input with name visible - already exists!
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:44
  [2] _add_input!(func::Function, attr::ComputePipeline.ComputeGraph, key::Symbol, value::Bool)
    @ ComputePipeline C:\Users\t26313tr\.julia\packages\ComputePipeline\soTSa\src\ComputePipeline.jl:717
  [3] add_input!
    @ C:\Users\t26313tr\.julia\packages\ComputePipeline\soTSa\src\ComputePipeline.jl:696 [inlined]
  [4] setproperty!(plot::LineSegments{Tuple{Vector{Point{2, Float64}}}}, key::Symbol, val::Bool)
    @ Makie C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\compute-plots.jl:94
  [5] (::Makie.var"#toggle_visibility!##0#toggle_visibility!##1"{Bool})(p::LineSegments{Tuple{Vector{Point{2, Float64}}}})
    @ Makie C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\makielayout\blocks\legend.jl:1160
  [6] foreach_plot(f::Makie.var"#toggle_visibility!##0#toggle_visibility!##1"{Bool}, entry::LegendEntry)
    @ Makie C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\makielayout\blocks\legend.jl:1151
  [7] toggle_visibility!
    @ C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\makielayout\blocks\legend.jl:1159 [inlined]
  [8] _toggle_hovered_legend_visibilities!(mpos::Tuple{Float64, Float64}, entry_groups::Vector{Tuple{Any, Vector{LegendEntry}}}, entryshades::Vector{Vector{Box}})
    @ Makie C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\makielayout\blocks\legend.jl:21
  [9] (::Makie.var"#2144#2145"{Events, Vector{Vector{Box}}, Observable{GeometryBasics.HyperRectangle{2, Int64}}, Observable{Vector{Tuple{Any, Vector{LegendEntry}}}}})(event::Makie.MouseButtonEvent)
    @ Makie C:\Users\t26313tr\.julia\packages\Makie\Vn16E\src\makielayout\blocks\legend.jl:365
 [10] notify
    @ C:\Users\t26313tr\.julia\packages\Observables\YdEbO\src\Observables.jl:206 [inlined]
 [11] setindex!
    @ C:\Users\t26313tr\.julia\packages\Observables\YdEbO\src\Observables.jl:123 [inlined]
 [12] (::GLMakie.var"#mousebuttons#mousebuttons##0"{Observable{Makie.MouseButtonEvent}})(window::GLFW.Window, button::GLFW.MouseButton, action::GLFW.Action, mods::Int32)
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\events.jl:104
 [13] _MouseButtonCallbackWrapper(window::GLFW.Window, button::GLFW.MouseButton, action::GLFW.Action, mods::Int32)
    @ GLFW C:\Users\t26313tr\.julia\packages\GLFW\wA4ue\src\callback.jl:46
 [14] macro expansion
    @ C:\Users\t26313tr\.julia\packages\GLFW\wA4ue\src\GLFW.jl:34 [inlined]
 [15] PollEvents
    @ C:\Users\t26313tr\.julia\packages\GLFW\wA4ue\src\glfw3.jl:773 [inlined]
 [16] pollevents(screen::GLMakie.Screen{GLFW.Window}, frame_state::Makie.TickState)
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\screen.jl:559
 [17] (::GLMakie.var"#on_demand_renderloop##0#on_demand_renderloop##1"{GLMakie.Screen{GLFW.Window}})()
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\screen.jl:1093
 [18] with_context(f::GLMakie.var"#on_demand_renderloop##0#on_demand_renderloop##1"{GLMakie.Screen{GLFW.Window}}, context::GLFW.Window)
    @ GLMakie.GLAbstraction C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\GLAbstraction\GLAbstraction.jl:59
 [19] on_demand_renderloop(screen::GLMakie.Screen{GLFW.Window})
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\screen.jl:1092
 [20] renderloop(screen::GLMakie.Screen{GLFW.Window})
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\screen.jl:1120
 [21] (::GLMakie.var"#start_renderloop!##0#start_renderloop!##1"{GLMakie.Screen{GLFW.Window}})()
    @ GLMakie C:\Users\t26313tr\.julia\packages\GLMakie\vdrwE\src\screen.jl:945
  • Makie v0.24.8, GLMakie v0.13.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions