Skip to content

Commit

Permalink
adds geom_contour test
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 2, 2024
1 parent 6ce7821 commit 467cec8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TidierPlots"
uuid = "337ecbd1-5042-4e2a-ae6f-ca776f97570a"
authors = ["Randall Boyes <[email protected]> and contributors"]
version = "0.6.0"
version = "0.6.1"

[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Expand Down
6 changes: 4 additions & 2 deletions src/draw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function Makie.SpecApi.Axis(plot::GGPlot)
# if there is a specified column transformation, use it
# otherwise use cat_inseq for string-like columns and as_is for everything else
if haskey(geom.column_transformations, aes)
plottable_data = geom.column_transformations[aes][2](aes, geom.column_transformations[aes][1], plot_data)
source_cols = [aes_dict[String(source)] for source in geom.column_transformations[aes][1]]
plottable_data = geom.column_transformations[aes][2](aes, source_cols, plot_data)
elseif eltype(plot_data[!, aes_dict[a]]) <: Union{AbstractString, AbstractChar}
plottable_data = cat_inseq(aes, [aes_dict[a]], plot_data)
else
Expand Down Expand Up @@ -111,7 +112,8 @@ function Makie.SpecApi.Axis(plot::GGPlot)
# if there is a specified column transformation, use it
# otherwise use cat_inseq for string-like columns and as_is for everything else
if haskey(geom.column_transformations, aes)
plottable_data = geom.column_transformations[aes][2](aes, geom.column_transformations[aes][1], plot_data)
source_cols = [aes_dict[String(source)] for source in geom.column_transformations[aes][1]]
plottable_data = geom.column_transformations[aes][2](aes, source_cols, plot_data)
elseif eltype(plot_data[!, aes_dict[a]]) <: Union{AbstractString, AbstractChar}
plottable_data = cat_inseq(aes, [aes_dict[a]], plot_data)
else
Expand Down
2 changes: 1 addition & 1 deletion test/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "5ca544e0ddaec04c2c0551102da3cb1f1f227a35"
project_hash = "34fb74b01d0db522e852db0c7efd7694431617fc"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
JDF = "babc3d20-cd49-4f60-a736-a8f9c08892d3"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
Loess = "4345ca2d-374a-55d4-8d30-97f9976e7612"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using JDF
using CategoricalArrays
using GLM
using Loess
using KernelDensity

# functions to compare two images using a difference hash
# essentially copied from ImageHashes.jl, but package is out of date
Expand Down
22 changes: 22 additions & 0 deletions test/test_geoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,26 @@
@test plot_images_equal(t, m)

end

@testset "geom_contour" begin
k = kde((penguins.bill_length_mm, penguins.bill_depth_mm))

m = Makie.plot(
Makie.SpecApi.GridLayout(
Makie.SpecApi.Axis(
plots = [
Makie.PlotSpec(
:Contour,
k.density
)
]
)
)
)

t = ggplot(penguins) +
geom_contour(aes(x = :bill_length_mm, y = :bill_depth_mm))

@test plot_images_equal(t, m)
end
end

0 comments on commit 467cec8

Please sign in to comment.