Skip to content

Commit

Permalink
adds test for colouring violin plots
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 3, 2024
1 parent eee32bc commit 51e294d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
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 = "34fb74b01d0db522e852db0c7efd7694431617fc"
project_hash = "2c5b2138cb65ab82766fae5af59fccb44af83f7f"

[[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
@@ -1,5 +1,6 @@
[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using CategoricalArrays
using GLM
using Loess
using KernelDensity
using Colors

# functions to compare two images using a difference hash
# essentially copied from ImageHashes.jl, but package is out of date
Expand Down
31 changes: 31 additions & 0 deletions test/test_geoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@
)

@test plot_images_equal(t, m)

colours = [
RGB(0/255, 114/255, 178/255), # blue
RGB(230/255, 159/255, 0/255), # orange
RGB(0/255, 158/255, 115/255), # green
RGB(204/255, 121/255, 167/255), # reddish purple
RGB(86/255, 180/255, 233/255), # sky blue
RGB(213/255, 94/255, 0/255), # vermillion
RGB(240/255, 228/255, 66/255), # yellow
]

m = Makie.plot(
Makie.SpecApi.GridLayout(
Makie.SpecApi.Axis(
plots = [
Makie.PlotSpec(
:Violin,
levelcode.(cat_array),
penguins.bill_length_mm;
color = (x -> colours[x]).(levelcode.(cat_array))
)]; xticks = (unique(levelcode.(cat_array)),
unique(cat_array))
)
)
)

t = ggplot(penguins) +
geom_violin(aes(x = :species, y = :bill_length_mm, color = :species))

@test plot_images_equal(t, m)

end

@testset "geom_hist" begin
Expand Down

0 comments on commit 51e294d

Please sign in to comment.