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

Regression: Series ignores color keyword #3301

Closed
felixcremer opened this issue Oct 17, 2023 · 3 comments · Fixed by #3303
Closed

Regression: Series ignores color keyword #3301

felixcremer opened this issue Oct 17, 2023 · 3 comments · Fixed by #3303
Labels

Comments

@felixcremer
Copy link
Contributor

felixcremer commented Oct 17, 2023

  • [x ] are you running newest version (version from docs) ?
    I am running current master.
  • [ x] can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • [x ] What platform + GPU are you on?
    julia> versioninfo()
    Julia Version 1.9.2
    Commit e4ee485e909 (2023-07-05 09:39 UTC)
    Platform Info:
    OS: Linux (x86_64-linux-gnu)
    CPU: 16 × AMD Ryzen 7 PRO 5850U with Radeon Graphics
    WORD_SIZE: 64
    LIBM: libopenlibm
    LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
    Threads: 1 on 16 virtual cores
    Environment:
    JULIA_IMAGE_THREADS = 1

The series plotting function ignores the color keyword and thereby does not work for series with more than 7 entries.

julia> args = ([1, 2, 4], [0.6819493475333241 0.6745600434404886 0.4889977072409113; 0.5746392538285008 0.48370986837296914 0.5911597718895916; 0.5394165394683204 0.7528767672734035 0.15235973948183312; 0.47188215926975174 0.304880337006751 0.42410626104380056; 0.09896354500102733 0.45223723495861734 0.7131082316166479; 0.27589708545765024 0.4734317984443611 0.36709014396134987; 0.003961860036966747 0.122883462295309 0.1857948965006283; 0.6121876274096806 0.3779821159724981 0.20031116825629225; 0.5186604908440713 0.4763178112949824 0.15799975734715332; 0.8099218402069105 0.8248055958641253 0.9740322214419064])
([1, 2, 4], [0.6819493475333241 0.6745600434404886 0.4889977072409113; 0.5746392538285008 0.48370986837296914 0.5911597718895916;  ; 0.5186604908440713 0.4763178112949824 0.15799975734715332; 0.8099218402069105 0.8248055958641253 0.9740322214419064])

julia> colormap = :Set1_5
:Set1_5

julia> n = 10
10

julia> color = resample_cmap(colormap, n)
10-element Array{RGBA{Float32},1} with eltype ColorTypes.RGBA{Float32}:
 RGBA{Float32}(0.894f0,0.102f0,0.11f0,1.0f0)
 RGBA{Float32}(0.5926667f0,0.27622223f0,0.382f0,1.0f0)
 RGBA{Float32}(0.29133335f0,0.45044443f0,0.654f0,1.0f0)
 RGBA{Float32}(0.24466667f0,0.55799997f0,0.578f0,1.0f0)
 RGBA{Float32}(0.2828889f0,0.6433333f0,0.386f0,1.0f0)
 RGBA{Float32}(0.36733332f0,0.6015555f0,0.36755556f0,1.0f0)
 RGBA{Float32}(0.498f0,0.43266666f0,0.52266663f0,1.0f0)
 RGBA{Float32}(0.6408889f0,0.32733333f0,0.568f0,1.0f0)
 RGBA{Float32}(0.82044446f0,0.41266665f0,0.284f0,1.0f0)
 RGBA{Float32}(1.0f0,0.498f0,0.0f0,1.0f0)

julia> Makie.series(args...; color)
ERROR: Not enough colors for number of categories. Categories: 10, colors: 7
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] categorical_colors
    @ ~/.julia/dev/Makie/src/conversions.jl:1222 [inlined]
  [3] categorical_colors(cs::Symbol, categories::Int64)
    @ Makie ~/.julia/dev/Makie/src/conversions.jl:1237
  [4] (::Makie.var"#2306#2314"{Int64})(color::Symbol, scolor::Nothing)
    @ Makie ~/.julia/dev/Makie/src/basic_recipes/series.jl:68
  [5] #map#157
    @ ~/.julia/dev/Makie/src/scenes.jl:185 [inlined]
  [6] map(f::Makie.var"#2306#2314"{Int64}, scene::Combined{Makie.series, Tuple{Vector{Vector{Point{2, Float32}}}}}, arg1::Observable{Any}, args::Observable{Any})
    @ Makie ~/.julia/dev/Makie/src/scenes.jl:182
  [7] plot!(plot::Combined{Makie.series, Tuple{Vector{Vector{Point{2, Float32}}}}})
    @ Makie ~/.julia/dev/Makie/src/basic_recipes/series.jl:72
  [8] plot!(scene::Scene, P::Type{Combined{Makie.series, Tuple{Vector{Int64}, Matrix{Float64}}}}, attributes::Attributes, input::Tuple{Observable{Vector{Int64}}, Observable{Matrix{Float64}}}, args::Observable{Tuple{Vector{Vector{Point{2, Float32}}}}})
    @ Makie ~/.julia/dev/Makie/src/interfaces.jl:398
  [9] plot!(::Scene, ::Type{Combined{Makie.series}}, ::Attributes, ::Vector{Int64}, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/dev/Makie/src/interfaces.jl:310
 [10] plot!(::Scene, ::Type{Combined{Makie.series}}, ::Attributes, ::Vector{Int64}, ::Matrix{Float64})
    @ Makie ~/.julia/dev/Makie/src/interfaces.jl:275
 [11] get_axis(fig::Any, P::Any, axis_kw::Dict, plot_attr::Any, plot_args::Any)
    @ Makie ~/.julia/dev/Makie/src/figureplotting.jl:43
 [12] plot(::Type{Combined{Makie.series}}, ::Vector{Int64}, ::Vararg{Any}; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Pairs{Symbol, Vector{ColorTypes.RGBA{Float32}}, Tuple{Symbol}, NamedTuple{(:color,), Tuple{Vector{ColorTypes.RGBA{Float32}}}}})
    @ Makie ~/.julia/dev/Makie/src/figureplotting.jl:62
 [13] series(::Vector{Int64}, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Vector{ColorTypes.RGBA{Float32}}, Tuple{Symbol}, NamedTuple{(:color,), Tuple{Vector{ColorTypes.RGBA{Float32}}}}})
    @ Makie ~/.julia/dev/Makie/MakieCore/src/recipes.jl:35
 [14] top-level scope
    @ REPL[23]:1

This is a regression to Makie 0.19.10 and I suspect that this is due to PR #3275.

I can fix the series ignoring the color keyword by deleting this line:
delete!(plot_attr, :color) # Color may contain Cycled(1), which needs the axis to get resolved to a color
but then the tests fail with

  MethodError: no method matching to_color(::Cycled)
@SimonDanisch
Copy link
Member

Ugh :D This works if you create an axis manually, doesn't it?

@felixcremer
Copy link
Contributor Author

Yes it does.

@SimonDanisch
Copy link
Member

Maybe we could delete it conditionally if plot_attr.color[] isa Cycled...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants