Skip to content

Commit

Permalink
makin changes makin breakin changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 2, 2024
1 parent 76f4ab4 commit 098fa89
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
19 changes: 5 additions & 14 deletions src/geoms/geom_contour.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
function stat_density_2d(aes_dict::Dict{String, Symbol},
args_dict, required_aes::Vector{String}, plot_data::DataFrame)

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

k = kde((x, y))

required_aes = ["z"]

aes_dict["z"] = :z
delete!(aes_dict, "x")
delete!(aes_dict, "y")

return_data = Dict(:z => k.density)

return (aes_dict, args_dict, required_aes, return_data)
return (aes_dict, args_dict, new_required_aes, plot_data)
end

geom_tile = geom_template("geom_tile", ["x", "y", "z"], :Heatmap)
geom_contour = geom_template("geom_contour", ["x", "y"], :Contour; aes_function = stat_density_2d)
geom_contour = geom_template("geom_contour", ["x", "y"], :Contour;
aes_function = stat_density_2d,
column_transformations = Dict{Symbol, Pair{Vector{Symbol}, Function}}(:z => [:x, :y] => kernel_density_2d))
4 changes: 2 additions & 2 deletions src/geoms/geom_errorbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function geom_errorbar(args...; kwargs...)
["x", "ymin", "ymax"], # required aesthetics
:Rangebars, # function for visual layer
do_nothing,
Dict{Symbol, Function}();
Dict{Symbol, Pair{Vector{Symbol}, Function}}();
special_aes = Dict("width" => "whiskerwidth"))
end

Expand All @@ -21,7 +21,7 @@ function geom_errorbarh(args...; kwargs...)
["y", "xmin", "xmax"], # required aesthetics
:Rangebars, # function for visual layer
do_nothing,
Dict{Symbol, Function}();
Dict{Symbol, Pair{Vector{Symbol}, Function}}();
special_aes = Dict("width" => "whiskerwidth"))

end
Expand Down
4 changes: 2 additions & 2 deletions src/geoms/geom_hvline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function geom_hline(args...; kwargs...)
return build_geom(aes_dict, args_dict,
["yintercept"], # required aesthetics
:HLines,
do_nothing, Dict{Symbol, Function}()) # function for visual layer
do_nothing, Dict{Symbol, Pair{Vector{Symbol}, Function}}()) # function for visual layer
end

function geom_vline(args...; kwargs...)
Expand All @@ -27,7 +27,7 @@ function geom_vline(args...; kwargs...)
return build_geom(aes_dict, args_dict,
["xintercept"], # required aesthetics
:VLines,
do_nothing, Dict{Symbol, Function}()) # function for visual layer
do_nothing, Dict{Symbol, Pair{Vector{Symbol}, Function}}()) # function for visual layer
end

function geom_hline(plot::GGPlot, args...; kwargs...)
Expand Down
6 changes: 3 additions & 3 deletions src/geoms/geom_smooth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function geom_smooth(args...; kwargs...)
["x", "y"],
:Lines,
stat_linear,
Dict{Symbol, Function}()),
Dict{Symbol, Pair{Vector{Symbol}, Function}}()),
build_geom(aes_dict,
args_dict,
["x", "lower", "upper"],
:Band,
stat_linear,
Dict{Symbol, Function}())]
Dict{Symbol, Pair{Vector{Symbol}, Function}}())]
end
end

Expand All @@ -56,7 +56,7 @@ function geom_smooth(args...; kwargs...)
["x", "y"],
:Lines,
stat_loess,
Dict{Symbol, Function}())
Dict{Symbol, Pair{Vector{Symbol}, Function}}())
end

function stat_loess(aes_dict::Dict{String, Symbol},
Expand Down
2 changes: 1 addition & 1 deletion src/geoms/geom_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function geom_template(name::AbstractString,
required_aes::AbstractArray,
spec_api_function::Symbol;
aes_function::Function = do_nothing,
column_transformations::Dict{Symbol, Function} = Dict{Symbol, Function}(),
column_transformations::Dict{Symbol, Pair{Vector{Symbol}, Function}} = Dict{Symbol, Pair{Vector{Symbol}, Function}}(),
extra_args::Dict = Dict())

extract_geom_aes = make_aes_extractor(required_aes)
Expand Down
4 changes: 2 additions & 2 deletions src/geoms/geom_text.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
geom_text = geom_template("geom_text", ["x", "y"], :Text;
column_transformations = Dict{Symbol, Function}(:text => verbatim))
column_transformations = Dict{Symbol, Pair{Vector{Symbol}, Function}}(:text => [:text]=>verbatim))
geom_label = geom_template("geom_label", ["x", "y"], :Text;
column_transformations = Dict{Symbol, Function}(:text => verbatim))
column_transformations = Dict{Symbol, Pair{Vector{Symbol}, Function}}(:text => [:text]=>verbatim))
2 changes: 1 addition & 1 deletion src/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ verbatim = convert_to(String)
function number_on_axis(target::Symbol, source::Vector{Symbol}, data::DataFrame)
return Dict{Symbol, PlottableData}(
target => PlottableData(
data[!, source[1]], # get the column out of the dataframe
data[!, source[1]], # get the column out of the dataframe
identity, # do nothing to it
Symbol(String(target) * "ticks"), # the axis label it will have, e.g. :xticks
Makie.automatic # calculate those ticks automatically
Expand Down

0 comments on commit 098fa89

Please sign in to comment.