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

Merging of Themes / Attributes with duplicated entries ignores rightmost value #4419

Open
3 tasks done
haakon-e opened this issue Sep 27, 2024 · 0 comments
Open
3 tasks done
Labels
Attributes Plot, Block and Scene Attributes bug Makie Backend independent issues (Makie core)

Comments

@haakon-e
Copy link
Contributor

Merging of Themes / Attributes with duplicated entries does not work how Base.merge does.

julia> theme1 = Theme(fontsize=8)
Attributes with 1 entry:
  fontsize => 8

julia> theme2 = Theme(fontsize=800)
Attributes with 1 entry:
  fontsize => 800

julia> merge(theme1, theme2)
Attributes with 1 entry:
  fontsize => 8

I would expect the result of the merge to be:

julia> merge(theme1, theme2)
Attributes with 1 entry:
  Axis => Attributes with 1 entry:
    titlesize => 100

which is the effect of e.g. set_theme!, update_theme!, with_theme.

Makie.merge does not have its own docstring explaining this, so if you do ?merge or ?Makie.merge you'll be shown explanations for other types, all of which tell you variants of the docs for Base.merge (my emphasis):

merge(d::AbstractDict, others::AbstractDict...)

Construct a merged collection from the given collections. If necessary, the types of the resulting collection will be promoted to accommodate the types of the merged collections. If the same key is present in another collection, the value for that key will be the value it has in the last collection listed.

Relevant LOC:

function merge_attributes!(input::Attributes, theme::Attributes)
for (key, value) in attributes(theme)
if !haskey(input, key)
input[key] = value
else
current_value = input[key]
tvalue = to_value(value)
if tvalue isa Attributes && current_value isa Attributes
# if nested attribute, we merge recursively
merge_attributes!(current_value, tvalue)
end
# we're good! input already has a value, can ignore theme
end
end
return input
end


  • what version of Makie are you running? (]st -m Makie) v0.21.11
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on? Mac M1
@haakon-e haakon-e added the bug label Sep 27, 2024
@haakon-e haakon-e changed the title Merging of Themes / Attributes with duplicated entries ignores rightmost attribute Merging of Themes / Attributes with duplicated entries ignores rightmost value Sep 27, 2024
@haakon-e haakon-e mentioned this issue Sep 30, 2024
5 tasks
@ffreyer ffreyer added Makie Backend independent issues (Makie core) Attributes Plot, Block and Scene Attributes labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Attributes Plot, Block and Scene Attributes bug Makie Backend independent issues (Makie core)
Projects
None yet
Development

No branches or pull requests

2 participants