Skip to content

Commit

Permalink
testing options for aes function support
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 4, 2024
1 parent a152bd6 commit 8a8c882
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TidierPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export scale_colour_manual, scale_color_manual

export cat_inseq, cat_inorder, number_on_axis, as_is, discard, verbatim, kernel_density_2d
export as_color
export aesthetics_function

const plot_log = Ref{Bool}(true)
const plot_show = Ref{Bool}(true)
Expand Down
21 changes: 21 additions & 0 deletions src/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ end

discard = AesTransform(discard_fn)

# generic function -> AesTransform creator

function aesthetics_function(generic_fn::Function)
function aes_fn(target::Symbol, source::Vector{Symbol}, data::DataFrame)
return Dict{Symbol, PlottableData}(
target => PlottableData(
data[!, source[1]], # get the column out of the dataframe
generic_fn, # apply generic_fn to it
nothing,
nothing
)
)
end

return AesTransform(aes_fn)
end

import Base.:>>

Base.:>>(sym::Symbol, fn::Function) = aesthetics_function(fn)(sym)

# tweaks
# takes an existing PlottableData object and modifies the makie_function

Expand Down

0 comments on commit 8a8c882

Please sign in to comment.