Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 18, 2024
2 parents b068cbe + 541eb8c commit cdb5e2a
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/geoms/geom_boxplot.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
function boxplot_groups(aes_dict::Dict{String, Symbol},
args_dict::Dict{Any, Any}, required_aes::Vector{String}, plot_data::DataFrame)

factor_aes = [aes for (aes, v) in aes_dict if eltype(plot_data[!, v]) <: Union{AbstractString, AbstractChar, CategoricalValue}]

main_factor_aes = "x"

if "y" in factor_aes && !("x" in factor_aes)
required_aes = ["y", "x"]
args_dict["orientation"] = :horizontal
main_factor_aes = "y"
end

dodge_aes = [aes for aes in factor_aes if aes_dict[aes] != aes_dict[main_factor_aes]]

if length(dodge_aes) > 1
@warn "Too many categorical aes specified, can't select dodge automatically"
end

if length(dodge_aes) != 0
aes_dict["dodge"] = aes_dict[dodge_aes[1]]
end

return (aes_dict, args_dict, required_aes, plot_data)
end

"""
geom_boxplot(aes(...), ...)
geom_boxplot(plot::GGPlot, aes(...), ...)
Expand All @@ -12,14 +38,15 @@ Compactly displays the distribution of continuous data.
# Required Aesthetics
- `x` OR `y`
- `x`
- `y`
# Supported Optional Aesthetics (See [`aes`](@ref) for specification options)
TBD
- colour/color
# Supported Options
TBD
"""
geom_boxplot = geom_template("geom_boxplot", ["x", "y"], :BoxPlot)
geom_boxplot = geom_template("geom_boxplot", ["x", "y"], :BoxPlot; aes_function = boxplot_groups)

2 comments on commit cdb5e2a

@rdboyes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105136

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.3 -m "<description of version>" cdb5e2afe2f9d55c092dd70392e2d43e277be6d5
git push origin v0.7.3

Please sign in to comment.