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

Bad error message when color is a number #3085

Closed
pzabka opened this issue Jul 23, 2023 · 2 comments
Closed

Bad error message when color is a number #3085

pzabka opened this issue Jul 23, 2023 · 2 comments
Labels

Comments

@pzabka
Copy link

pzabka commented Jul 23, 2023

This might be related to issue #1178 and #1198
I guess it is a little bit ambiguous when the color is given just as a number, but the error message is quite unhelpful.

MWE:

using GLMakie

x = range(0, 10, length=100)
scatter(x, sin, color=1)

Error:

ERROR: UndefVarError: `intensity` not defined
Stacktrace:
  [1] assemble_colors(#unused#::Float64, color::Observable{Any}, plot::Scatter{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\colorsampler.jl:272
  [2] color_and_colormap!(plot::Scatter{Tuple{Vector{Point{2, Float32}}}}, colors::Observable{Any})
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:2
  [3] color_and_colormap!(plot::Scatter{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:2
  [4] calculated_attributes!
    @ ...\.julia\packages\Makie\uAmck\src\interfaces.jl:45 [inlined]
  [5] calculated_attributes!
    @ ...\.julia\packages\MakieCore\bttjb\src\basic_plots.jl:118 [inlined]
  [6] Scatter{Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, typeof(sin)}}(scene::Scene, attributes::Attributes, input::Tuple{Observable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, Observable{typeof(sin)}}, args::Observable{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:207
  [7] plot!(scene::Scene, P::Type{Scatter{Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, typeof(sin)}}}, attributes::Attributes, input::Tuple{Observable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, Observable{typeof(sin)}}, args::Observable{Tuple{Vector{Point{2, Float32}}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:392
  [8] plot!(::Scene, ::Type{Scatter}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; 
kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:310
  [9] plot!(::Scene, ::Type{Scatter}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Function)
    @ Makie ...\.julia\packages\Makie\uAmck\src\interfaces.jl:275
 [10] plot(::Type{Scatter}, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:color,), Tuple{Float64}}})
    @ Makie ...\.julia\packages\Makie\uAmck\src\figureplotting.jl:48
 [11] scatter(::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:color,), Tuple{Float64}}})
    @ MakieCore ...\.julia\packages\MakieCore\bttjb\src\recipes.jl:34
 [12] top-level scope
    @ ...\mwe.jl:4
@FelixNoessler
Copy link

Hello,

I get the same error message, when I try to create a Legend:

using CairoMakie

let 
    color_values = 1:5
    colorrange = (1,5)

    fig = Figure()
    Axis(fig[1,1])

    for i in eachindex(color_values)
        scatter!(1:10, i .+ (1:10);
            color=color_values[i],
            colorrange,
            colormap=:viridis,
            label="val = $(color_values[i])")
    end

    ### the legend produces the error message
    axislegend()

    fig
end

I guess that this code should run.. it was also working for an earlier CairoMakie/GLMakie version. I am using now:

[13f3f980] CairoMakie v0.10.7
[e9467ef8] GLMakie v0.8.7

@SimonDanisch
Copy link
Member

Fixed in #3086

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

3 participants