diff --git a/ReferenceTests/src/tests/examples2d.jl b/ReferenceTests/src/tests/examples2d.jl index e0de6938e1a..feddaf2ad04 100644 --- a/ReferenceTests/src/tests/examples2d.jl +++ b/ReferenceTests/src/tests/examples2d.jl @@ -1496,6 +1496,33 @@ end fig end +@reference_test "Violin" begin + fig = Figure() + + categories = vcat(fill(1, 300), fill(2, 300), fill(3, 300)) + values = vcat(RNG.randn(300), (1.5 .* RNG.rand(300)).^2, -(1.5 .* RNG.rand(300)).^2) + violin(fig[1, 1], categories, values) + + dodge = RNG.rand(1:2, 900) + 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]) @@ -1577,3 +1604,220 @@ end sleep(1) # give the async operations some time f end + +@reference_test "boxplot" begin + fig = Figure() + + categories = vcat(fill(1, 300), fill(2, 300), fill(3, 300)) + values = RNG.randn(900) .+ range(-1, 1, length=900) + boxplot(fig[1, 1], categories, values) + + dodge = RNG.rand(1:2, 900) + 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, :orange], 900) + ) + + 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 + Makie.RAINCLOUD_RNG[] = RNG.STABLE_RNG + 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 diff --git a/ReferenceTests/src/tests/examples3d.jl b/ReferenceTests/src/tests/examples3d.jl index 63c096f2898..49b5025051e 100644 --- a/ReferenceTests/src/tests/examples3d.jl +++ b/ReferenceTests/src/tests/examples3d.jl @@ -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 diff --git a/ReferenceTests/src/tests/figures_and_makielayout.jl b/ReferenceTests/src/tests/figures_and_makielayout.jl index b61da7b1348..2e3a28d2ca2 100644 --- a/ReferenceTests/src/tests/figures_and_makielayout.jl +++ b/ReferenceTests/src/tests/figures_and_makielayout.jl @@ -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)) + Makie.Button(f[1, 1:2]) + Makie.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) + + Makie.Slider(f[3, 3]) + sl = Makie.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 \ No newline at end of file diff --git a/ReferenceTests/src/tests/short_tests.jl b/ReferenceTests/src/tests/short_tests.jl index f05977e1324..6d111230245 100644 --- a/ReferenceTests/src/tests/short_tests.jl +++ b/ReferenceTests/src/tests/short_tests.jl @@ -324,4 +324,4 @@ end # f.scene.events.scroll[] = (0, -10) # # reference test the zoomed out plot # f -# end \ No newline at end of file +# end