-
Notifications
You must be signed in to change notification settings - Fork 8
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
@aes macro update to support calculated aesthetics #71
Comments
Can you give an example of how to call Is the goal to have something like |
Sorry I have been so slow on this one. If you'd like to work on it, I can outline what I think is the best way to do it in a reply to this message. Otherwise, I'm hoping to get to it soon-ish. |
The output needs to be in the form of a "column transformation" - the way I've set up the draw code to run the calculations, that looks like an entry in a key => pair Dict with the following parts:
function sort_by_fn(target::Symbol, source::Vector{Symbol}, data::DataFrame)
perm = sortperm(data[!, source[2]])
return Dict{Symbol, PlottableData}(
target => PlottableData(
data[perm, source[1]],
identity,
nothing,
nothing
)
)
end
sort_by = AesTransform(sort_by_fn) |
I know the complexity is weirdly high here - and I'm open to any rewrite suggestions. This was the simplest structure I could come up with that was also flexible enough to encode all of the possible aes requirements (look for example at |
Does your code currently call TidierData? My suggestion would be to pass the transformation through |
It does - what would mutate return, though? Would it be DataFrames syntax? We still have to store that and run it later, since when the aes is called, we don't necessarily have access to the DataFrame that we're referencing |
That was going to be my question. Isn't the underlying data part of the ggplot struct? If it was, I was thinking we could create a temporary column containing the mutated result and then reference that column. |
That was how I was originally doing it, but some of the Makie plots require inputs that can't be stored as a DataFrame column (e.g. |
Is there an existing way to have |
Would wrapping it inside of an anonymous function work? For example, I'm still trying to wrap my head around why we couldn't modify the struct in place rather than defer the evaluation. I haven't tried it, so you definitely have a better understanding. |
It's because in call like this: ggplot(penguins) +
geom_point(@aes(bill_length_mm/10, bill_depth_mm))
But wrapping it in an anonymous function could work, yes |
Got it. Another option would be to wrap it inside of an expression. We would interpolate the expression into For example, |
I've made progress on this - I was removing some of the "deep type piracy" and made it easier to implement as a consequence. Its almost working, but there's a questionable Line 44 in 45a102f
|
Thanks! I will take a look at this. |
0.6.3 added support for calculated aesthetics in the function
aes
- need to extend this feature to the macro@aes
.The text was updated successfully, but these errors were encountered: