Skip to content

Commit

Permalink
adds geom_density
Browse files Browse the repository at this point in the history
This commit contains everything required to add a new geom (geom_density).
  • Loading branch information
rdboyes committed Sep 20, 2023
1 parent cc5ca8e commit ecfc96f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/TidierPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include("geom_bar.jl")
include("geom_boxplot.jl")
include("geom_contour.jl")
include("geom_errorbar.jl")
include("geom_density.jl")
include("geom_path.jl")
include("geom_point.jl")
include("geom_smooth.jl")
Expand All @@ -33,6 +34,7 @@ export @geom_path, @geom_line, @geom_step
export @geom_violin, @geom_boxplot
export @geom_contour, @geom_tile
export @geom_text, @geom_label
export @geom_density
export @labs, @lims
export @scale_x_continuous, @scale_y_continuous
export @scale_x_log10, @scale_y_log10, @scale_x_log2, @scale_y_log2, @scale_x_log, @scale_y_log
Expand Down
37 changes: 37 additions & 0 deletions src/geom_density.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
@geom_density(aes(...), ...)
Represent data as a smooth density curve.
# Arguments
- `aes(...)`: the names of the columns in the plot DataFrame and their corresponding aesthetic.
- `...`: options that are not mapped to a column
# Required Aesthetics
- x
# Supported Optional Aesthetics
- alpha
- stroke
- colour/color
# Supported Options
- alpha
- stroke
- colour/color
"""
macro geom_density(exprs...)
aes_dict, args_dict = extract_aes(:($(exprs)))

args_dict["geom_name"] = "geom_density"

return build_geom(aes_dict, args_dict,
["x"], # required aesthetics
nothing, # function for visual layer
AlgebraOfGraphics.density()) # function for analysis layer
end

0 comments on commit ecfc96f

Please sign in to comment.