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

Unable to pass attributes if re-directed by recipe #3904

Open
Moelf opened this issue May 29, 2024 · 4 comments
Open

Unable to pass attributes if re-directed by recipe #3904

Moelf opened this issue May 29, 2024 · 4 comments
Labels
bug conversions Mainly `convert_arguments` Makie Backend independent issues (Makie core) recipes

Comments

@Moelf
Copy link
Contributor

Moelf commented May 29, 2024

Building on top of the examples: https://docs.makie.org/dev/tutorials/wrap-existing-recipe

The tutorial has this snippet:

function Makie.plot!(plot::Hist{<:Tuple{<:MyHist}})
    # Only forward valid attributes for BarPlot
    valid_attributes = Makie.shared_attributes(plot, BarPlot)
    barplot!(plot, valid_attributes, plot[1])
end

h = MyHist([1, 10, 100], 1:3)
hist(h; color=:red, direction=:x)

Now, let's say user wants to also customize Makie.hist(myhist; clamp_bincounts = ...), they can't get this to work.

In particular, it is not enough to register these:

Makie.used_attributes(::Type{<:Hist}, h::MyHist) = (:clamp_bincounts, )
Makie.used_attributes(::Type{<:BarPlot}, h::MyHist) = (:clamp_bincounts, )

because by the time we're inside our own function Makie.plot!(plot::Hist{<:Tuple{<:MyHist}}) method, the attributes no longer contain the keyword argument we need.

@asinghvi17

@SimonDanisch
Copy link
Member

used_attributes is for passing arguments to convert_arguments, which is where clamp_bincounts should be implemented, since you can't add custom attributes to an existing recipe.

@Moelf
Copy link
Contributor Author

Moelf commented May 30, 2024

as you may recall, that tutorial specifically deal with situation where it can't be implemented as convert_arguments -- in this case, I already have histograms made, I can't convert them back to inputs to Makie.hist(), it's conceptually impossible.

@t-bltg t-bltg added the recipes label Jun 6, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 28, 2024

Shouldn't it be used_attributes(::Type{::MyHist}, ::InputType) = ...?

@asinghvi17
Copy link
Member

The problem is that used_attributes consumes those kwargs, I think...

@ffreyer ffreyer added Makie Backend independent issues (Makie core) conversions Mainly `convert_arguments` labels Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug conversions Mainly `convert_arguments` Makie Backend independent issues (Makie core) recipes
Projects
None yet
Development

No branches or pull requests

5 participants