Skip to content

Commit

Permalink
half completed geom_contour
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Mar 24, 2024
1 parent 3c7fe49 commit f6659f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
Loess = "4345ca2d-374a-55d4-8d30-97f9976e7612"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down
1 change: 1 addition & 0 deletions src/TidierPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using TidierData
# for geom_smooth fits
using GLM
using Loess
using KernelDensity

include("structs.jl")

Expand Down
19 changes: 18 additions & 1 deletion src/geoms/geom_contour.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
geom_tile = geom_template("geom_tile", ["x", "y", "z"], :Heatmap)
geom_contour = geom_template("geom_contour", ["x", "y", "z"], :Contour)
geom_contour = geom_template("geom_contour", ["x", "y"], :Contour; aes_function = stat_density_2d)

function stat_density_2d(aes_dict::Dict{String, Symbol},
args_dict::Dict{String, Any}, required_aes::Vector{String}, plot_data::DataFrame)

x = plot_data[!, aes_dict["x"]]
y = plot_data[!, aes_dict["y"]]

k = kde((penguins.bill_length_mm, penguins.bill_depth_mm))

required_aes = ["z"]

return_data = DataFrame(
"z" => k.density
)

return (aes_dict, args_dict, required_aes, return_data)
end

0 comments on commit f6659f1

Please sign in to comment.