Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference image tests for untested plots/blocks #4433

Merged
merged 30 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
12949fe
add test for boxplot
ffreyer Oct 1, 2024
41c5acf
add test for crossbar
ffreyer Oct 1, 2024
ea73679
add qqnorm and qqplot
ffreyer Oct 1, 2024
cdabe99
add ecdfplot
ffreyer Oct 1, 2024
ac7bda0
add rainclouds
ffreyer Oct 1, 2024
c4fdbc4
add series
ffreyer Oct 1, 2024
657445f
add stairs
ffreyer Oct 1, 2024
6bcfabe
add stem
ffreyer Oct 1, 2024
f57e8cc
add waterfall
ffreyer Oct 1, 2024
abd06a9
add test for Button, Slider, Toggle, IntervalSlider
ffreyer Oct 2, 2024
4abca78
add test for ablines, h/vlines and h/vspan
ffreyer Oct 2, 2024
9a25178
add another violin test
ffreyer Oct 2, 2024
ba97237
add volumeslices test
ffreyer Oct 2, 2024
620bcc7
extend test with Textbox
ffreyer Oct 2, 2024
70a8727
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 2, 2024
5e439ab
fix test name
ffreyer Oct 2, 2024
4c955b6
Merge branch 'ff/missing-refimages' of https://github.com/MakieOrg/Ma…
ffreyer Oct 2, 2024
a29ede1
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 2, 2024
732537d
fix bad block
ffreyer Oct 4, 2024
ed79f4f
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 4, 2024
a433874
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 7, 2024
54fe949
Merge branch 'ff/missing-refimages' of https://github.com/MakieOrg/Ma…
ffreyer Oct 7, 2024
5f6b1cd
fix name conflicts with Bonito
ffreyer Oct 7, 2024
f3f762c
reduce symmetry
ffreyer Oct 7, 2024
966efc3
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 10, 2024
8561447
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 15, 2024
d6b623f
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 15, 2024
ad90ce2
stabilize test
ffreyer Oct 15, 2024
782e482
Merge branch 'master' into ff/missing-refimages
ffreyer Oct 15, 2024
15b8ce1
fix module
ffreyer Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,33 @@ end
fig
end

@reference_test "Violin" begin
fig = Figure()

categories = RNG.rand(1:3, 1000)
values = RNG.randn(1000)
violin(fig[1, 1], categories, values)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually stopped doing reference tests where there's some kind of symmetry in the data. Like here, all groups have the same data basically, so if there was something wrong in the mapping from categories to groups, you wouldn't see it here. Instead I'd add the group values to the data maybe, so you'd see three shifted violins, or something to that effect.


dodge = RNG.rand(1:2, 1000)
violin(fig[1, 2], categories, values, dodge = dodge,
color = map(d->d==1 ? :yellow : :orange, dodge),
strokewidth = 2, strokecolor = :black, gap = 0.1, dodge_gap = 0.5
)

violin(fig[2, 1], categories, values, orientation = :horizontal,
color = :gray, side = :left
)

violin!(categories, values, orientation = :horizontal,
color = :yellow, side = :right, strokewidth = 2, strokecolor = :black,
weights = abs.(values)
)

# TODO: test bandwidth, boundary

fig
end

@reference_test "Clip planes - CairoMakie overrides" begin
f = Figure()
a = Axis(f[1, 1])
Expand Down Expand Up @@ -1551,3 +1578,219 @@ end
sleep(1) # give the async operations some time
f
end

@reference_test "boxplot" begin
fig = Figure()

categories = RNG.rand(1:3, 1000)
values = RNG.randn(1000)
boxplot(fig[1, 1], categories, values)

dodge = RNG.rand(1:2, 1000)
boxplot(fig[1, 2], categories, values, dodge = dodge, show_notch = true,
color = map(d->d==1 ? :blue : :red, dodge),
outliercolor = RNG.rand([:red, :green, :blue, :black, :yellow], 1000)
)

ax_vert = Axis(fig[2,1];
xlabel = "categories",
ylabel = "values",
xticks = (1:3, ["one", "two", "three"])
)
ax_horiz = Axis(fig[2,2];
xlabel="values",
ylabel="categories",
yticks=(1:3, ["one", "two", "three"])
)

weights = 1.0 ./ (1.0 .+ abs.(values))
boxplot!(ax_vert, categories, values, orientation=:vertical, weights = weights,
gap = 0.5,
show_notch = true, notchwidth = 0.75,
markersize = 5, strokewidth = 2.0, strokecolor = :black,
medianlinewidth = 5, mediancolor = :orange,
whiskerwidth = 1.0, whiskerlinewidth = 3, whiskercolor = :green,
outlierstrokewidth = 1.0, outlierstrokecolor = :red,
width = 1.5,

)
boxplot!(ax_horiz, categories, values; orientation=:horizontal)

fig
end

@reference_test "crossbar" begin
fig = Figure()

xs = [1, 1, 2, 2, 3, 3]
ys = RNG.rand(6)
ymins = ys .- 1
ymaxs = ys .+ 1
dodge = [1, 2, 1, 2, 1, 2]

crossbar(fig[1, 1], xs, ys, ymins, ymaxs, dodge = dodge, show_notch = true)

crossbar(fig[1, 2], xs, ys, ymins, ymaxs,
dodge = dodge, dodge_gap = 0.25,
gap = 0.05,
midlinecolor = :blue, midlinewidth = 5,
show_notch = true, notchwidth = 0.3,
notchmin = ys .- (0.05:0.05:0.3), notchmax = ys .+ (0.3:-0.05:0.05),
strokewidth = 2, strokecolor = :black,
orientation = :horizontal, color = :lightblue
)
fig
end

@reference_test "ecdfplot" begin
f = Figure(size = (500, 250))

x = RNG.randn(200)
ecdfplot(f[1, 1], x, color = (:blue, 0.3))
ecdfplot!(x, color = :red, npoints=10, step = :pre, linewidth = 3)
ecdfplot!(x, color = :orange, npoints=10, step = :center, linewidth = 3)
ecdfplot!(x, color = :green, npoints=10, step = :post, linewidth = 3)

w = @. x^2 * (1 - x)^2
ecdfplot(f[1, 2], x)
ecdfplot!(x; weights = w, color=:orange)

f
end

@reference_test "qqnorm" begin
fig = Figure()
xs = 2 .* RNG.randn(10) .+ 3
qqnorm(fig[1, 1], xs, qqline = :fitrobust, strokecolor = :cyan, strokewidth = 2)
qqnorm(fig[1, 2], xs, qqline = :none, markersize = 10, marker = Rect, markercolor = :red)
qqnorm(fig[2, 1], xs, qqline = :fit, linestyle = :dash, linewidth = 4)
qqnorm(fig[2, 2], xs, qqline = :identity, color = :orange)
fig
end

@reference_test "qqplot" begin
fig = Figure()
xs = 2 .* RNG.randn(10) .+ 3; ys = RNG.randn(10)
qqplot(fig[1, 1], xs, ys, qqline = :fitrobust, strokecolor = :cyan, strokewidth = 2)
qqplot(fig[1, 2], xs, ys, qqline = :none, markersize = 10, marker = Rect, markercolor = :red)
qqplot(fig[2, 1], xs, ys, qqline = :fit, linestyle = :dash, linewidth = 4)
qqplot(fig[2, 2], xs, ys, qqline = :identity, color = :orange)
fig
end

@reference_test "rainclouds" begin
data = RNG.randn(1000)
data[1:200] .+= 3
data[201:500] .-= 3
data[501:end] .= 3 .* abs.(data[501:end]) .- 3
labels = vcat(fill("red", 500), fill("green", 500))

fig = Figure()
rainclouds(fig[1, 1], labels, data, plot_boxplots = false, cloud_width = 2.0,
markersize = 5.0)
rainclouds(fig[1, 2], labels, data, color = labels, orientation = :horizontal, cloud_width = 2.0)
rainclouds(fig[2, 1], labels, data, clouds = hist, hist_bins = 30, boxplot_nudge = 0.1,
center_boxplot = false, boxplot_width = 0.2, whiskerwidth = 1.0, strokewidth = 3.0)
rainclouds(fig[2, 2], labels, data, color = labels, side = :right, violin_limits = extrema)
fig
end

@reference_test "series" begin
fig = Figure()
data = cumsum(RNG.randn(4, 21), dims = 2)

ax, sp = series(fig[1, 1], data, labels=["label $i" for i in 1:4],
linewidth = 4, linestyle = :dot, markersize = 15, solid_color = :black)
axislegend(ax, position = :lt)

ax, sp = series(fig[2, 1], data, labels=["label $i" for i in 1:4], markersize = 5.0,
marker = Circle, markercolor = :transparent, strokewidth = 2.0, strokecolor = :black)
axislegend(ax, position = :lt)

fig
end

@reference_test "stairs" begin
f = Figure()

xs = LinRange(0, 4pi, 21)
ys = sin.(xs)

stairs(f[1, 1], xs, ys)
stairs(f[2, 1], xs, ys; step=:post, color=:blue, linestyle=:dash)
stairs(f[3, 1], xs, ys; step=:center, color=:red, linestyle=:dot)

f
end

@reference_test "stem" begin
f = Figure()

xs = LinRange(0, 4pi, 30)
stem(f[1, 1], xs, sin.(xs))

stem(f[1, 2], xs, sin,
offset = 0.5, trunkcolor = :blue, marker = :rect,
stemcolor = :red, color = :orange,
markersize = 15, strokecolor = :red, strokewidth = 3,
trunklinestyle = :dash, stemlinestyle = :dashdot)

stem(f[2, 1], xs, sin.(xs),
offset = LinRange(-0.5, 0.5, 30),
color = LinRange(0, 1, 30), colorrange = (0, 0.5),
trunkcolor = LinRange(0, 1, 30), trunkwidth = 5)

ax, p = stem(f[2, 2], 0.5xs, 2 .* sin.(xs), 2 .* cos.(xs),
offset = Point3f.(0.5xs, sin.(xs), cos.(xs)),
stemcolor = LinRange(0, 1, 30), stemcolormap = :Spectral, stemcolorrange = (0, 0.5))

center!(ax.scene)
zoom!(ax.scene, 0.8)
ax.scene.camera_controls.settings[:center] = false

f
end

@reference_test "waterfall" begin
y = [6, 4, 2, -8, 3, 5, 1, -2, -3, 7]

fig = Figure()
waterfall(fig[1, 1], y)
waterfall(fig[1, 2], y, show_direction = true, marker_pos = :cross,
marker_neg = :hline, direction_color = :yellow)

colors = Makie.wong_colors()
x = repeat(1:2, inner=5)
group = repeat(1:5, outer=2)

waterfall(fig[2, 1], x, y, dodge = group, color = colors[group],
show_direction = true, show_final = true, final_color=(colors[6], 1//3),
dodge_gap = 0.1, gap = 0.05)

x = repeat(1:5, outer=2)
group = repeat(1:2, inner=5)

waterfall(fig[2, 2], x, y, dodge = group, color = colors[group],
show_direction = true, stack = :x, show_final = true)

fig
end

@reference_test "ablines + hvlines + hvspan" begin
f = Figure()

ax = Axis(f[1, 1])
hspan!(ax, -1, -0.9, color = :lightblue, alpha = 0.5, strokewidth = 2, strokecolor = :black)
hspan!(ax, 0.9, 1, xmin = 0.2, xmax = 0.8)
vspan!(ax, -1, -0.9)
vspan!(ax, 0.9, 1, ymin = 0.2, ymax = 0.8, strokecolor = RGBf(0,1,0.1), strokewidth = 3)

ablines!([0.3, 0.7], [-0.2, 0.2], color = :orange, linewidth = 4, linestyle = :dash)

hlines!(ax, -0.8)
hlines!(ax, 0.8, xmin = 0.2, xmax = 0.8)
vlines!(ax, -0.8, color = :green, linewidth = 3)
vlines!(ax, 0.8, ymin = 0.2, ymax = 0.8, color = :red, linewidth = 3, linestyle = :dot)

f
end
14 changes: 14 additions & 0 deletions ReferenceTests/src/tests/examples3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,17 @@ end
ls2, pl = surface(f[1, 2], Makie.peaks(20); interpolate=false, axis=(; show_axis=false))
f
end

@reference_test "volumeslices" begin
r = range(-1, 1, length = 10)
data = RNG.rand(10,10,10)

fig = Figure()
volumeslices(fig[1, 1], r, r, r, data)
a, p = volumeslices(fig[1, 2], r, r, r, data, bbox_visible = false, colormap = :RdBu,
colorrange = (0.2, 0.8), lowclip = :black, highclip = :green)
p.update_xz[](3)
p.update_yz[](4)
p.update_xy[](10)
fig
end
34 changes: 34 additions & 0 deletions ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,39 @@ end
Makie.Checkbox(f[2, 3], checked = true, checkmarkcolor_checked = :black)
Makie.Checkbox(f[2, 4], checked = false, checkboxcolor_unchecked = :yellow)
Makie.Checkbox(f[2, 5], checked = true, checkboxcolor_checked = :orange)
f
end

@reference_test "Button - Slider - Toggle - Textbox" begin
f = Figure(size = (500, 250))
Button(f[1, 1:2])
Button(f[2, 1:2], buttoncolor = :orange, cornerradius = 20,
strokecolor = :red, strokewidth = 2, # TODO: allocate space for this
fontsize = 16, labelcolor = :blue)

IntervalSlider(f[1, 3])
sl = IntervalSlider(f[2, 3], range = 0:100, linewidth = 20,
color_inactive = :orange, color_active_dimmed = :lightgreen)
Makie.set_close_to!(sl, 30, 70)

Toggle(f[3, 1])
Toggle(f[4, 1], framecolor_inactive = :lightblue, rimfraction = 0.6)
Toggle(f[3, 2], active = true)
Toggle(f[4, 2], active = true, framecolor_inactive = :lightblue,
framecolor_active = :yellow, rimfraction = 0.6)

Slider(f[3, 3])
sl = Slider(f[4, 3], range = 0:100, linewidth = 20, color_inactive = :cyan,
color_active_dimmed = :lightgreen)
Makie.set_close_to!(sl, 30)

gl = GridLayout(f[5, 1:3])
Textbox(gl[1, 1])
Textbox(gl[1, 2], bordercolor = :red, cornerradius = 0,
placeholder = "test string", fontsize = 16, textcolor_placeholder = :blue)
tb = Textbox(gl[1, 3], bordercolor = :black, cornerradius = 20,
fontsize =10, textcolor = :red, boxcolor = :lightblue)
Makie.set!(tb, "some string")

f
end
2 changes: 1 addition & 1 deletion ReferenceTests/src/tests/short_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,4 @@ end
# f.scene.events.scroll[] = (0, -10)
# # reference test the zoomed out plot
# f
# end
# end
Loading