diff --git a/Project.toml b/Project.toml index 2ca467c..ec52638 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "StatsMakie" uuid = "65254759-4cff-5aa5-8326-61ce017a8c70" -version = "0.1.5" +version = "0.2" [deps] AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e" @@ -17,7 +17,7 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] -AbstractPlotting = "0.9.27" +AbstractPlotting = "0.10" Distributions = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23" GLM = "1.3" IntervalSets = "0.3, 0.4" diff --git a/src/StatsMakie.jl b/src/StatsMakie.jl index 4738965..a4f00b4 100644 --- a/src/StatsMakie.jl +++ b/src/StatsMakie.jl @@ -6,7 +6,7 @@ using AbstractPlotting import AbstractPlotting: conversion_trait, convert_arguments, used_attributes, plot!, combine, to_plotspec using AbstractPlotting: plottype, Plot, PlotFunc, to_tuple using AbstractPlotting: node_pairs, extrema_nan, automatic, default_theme -using AbstractPlotting: GeometryTypes +using AbstractPlotting: GeometryBasics using AbstractPlotting: ConversionTrait, el32convert, categoric_labels, categoric_position, categoric_range # Moved in https://github.com/JuliaGizmos/Observables.jl/pull/40 diff --git a/src/recipes/crossbar.jl b/src/recipes/crossbar.jl index 808c5c0..1f025de 100644 --- a/src/recipes/crossbar.jl +++ b/src/recipes/crossbar.jl @@ -70,30 +70,32 @@ function AbstractPlotting.plot!(plot::CrossBar) end # when notchmin = ymin || notchmax == ymax, fill disappears from # half the box. first ∘ StatsBase.rle removes adjacent duplicates. - boxes = - GeometryTypes.GLNormalMesh.(first.(StatsBase.rle.(Base.vect.( - fpoint.(l, ymin), - fpoint.(r, ymin), - fpoint.(r, nmin), - fpoint.(m .+ nw .* hw, y), # notch right - fpoint.(r, nmax), - fpoint.(r, ymax), - fpoint.(l, ymax), - fpoint.(l, nmax), - fpoint.(m .- nw .* hw, y), # notch left - fpoint.(l, nmin), - )))) + points = first.(StatsBase.rle.(Base.vect.( + fpoint.(l, ymin), + fpoint.(r, ymin), + fpoint.(r, nmin), + fpoint.(m .+ nw .* hw, y), # notch right + fpoint.(r, nmax), + fpoint.(r, ymax), + fpoint.(l, ymax), + fpoint.(l, nmax), + fpoint.(m .- nw .* hw, y), # notch left + fpoint.(l, nmin), + ))) + boxes = if points isa AbstractVector{<: Point} # poly + [GeometryBasics.triangle_mesh(points)] + else # multiple polys (Vector{Vector{<:Point}}) + GeometryBasics.triangle_mesh.(points) + end midlines = Pair.(fpoint.(m .- nw .* hw, y), fpoint.(m .+ nw .* hw, y)) else boxes = frect.(l, ymin, bw, ymax .- ymin) midlines = Pair.(fpoint.(l, y), fpoint.(r, y)) end - return [boxes;], [midlines;] end boxes = @lift($signals[1]) midlines = @lift($signals[2]) - poly!( plot, boxes, diff --git a/test/runtests.jl b/test/runtests.jl index 67e163f..d2814ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,7 @@ using AbstractPlotting, StatsMakie, StatsBase using Test using Random: seed! -using AbstractPlotting.GeometryTypes: HyperRectangle +using AbstractPlotting.GeometryBasics: FRect2D using Distributions using KernelDensity: kde @@ -12,17 +12,17 @@ seed!(0) p = crossbar(1, 3, 2, 4) @test p.plots[end] isa CrossBar @test p.plots[end].plots[1] isa Poly - @test p.plots[end].plots[1][1][] == HyperRectangle{2,Float32}[HyperRectangle{2,Float32}(Float32[0.6, 2.0], Float32[0.8, 2.0]),] + @test p.plots[end].plots[1][1][] == [FRect2D(Float32[0.6, 2.0], Float32[0.8, 2.0]),] @test p.plots[end].plots[2] isa LineSegments @test p.plots[end].plots[2][1][] == Point{2,Float32}[Float32[0.6, 3.0], Float32[1.4, 3.0]] - p = crossbar(1, 3, 2, 4; show_notch = true, notchmin = 2.5, notchmax = 3.5) + p = crossbar(1, 3, 2, 4; show_notch = true, notchmin = 2.5, notchmax = 3.5); @test p.plots[end] isa CrossBar @test p.plots[end].plots[1] isa Poly @test p.plots[end].plots[1][1][][1] isa AbstractPlotting.AbstractMesh poly = Point{2,Float32}[[0.6, 2.0], [1.4, 2.0], [1.4, 2.5], [1.2, 3.0], [1.4, 3.5], [1.4, 4.0], [0.6, 4.0], [0.6, 3.5], [0.8, 3.0], [0.6, 2.5]] - @test map(Point2f0, p.plots[end].plots[1][1][][1].vertices) == poly + @test map(Point2f0, p.plots[end].plots[1][1][][1].position) == poly @test p.plots[end].plots[2] isa LineSegments @test p.plots[end].plots[2][1][] == Point{2,Float32}[Float32[0.8, 3.0], Float32[1.2, 3.0]] end @@ -61,12 +61,12 @@ end @test plts[3] isa CrossBar @test plts[3].plots[1] isa Poly - poly = HyperRectangle{2,Float32}[ - HyperRectangle{2,Float32}(Float32[0.6, 5.75], Float32[0.8, 9.5]), - HyperRectangle{2,Float32}(Float32[1.6, 25.75], Float32[0.8, 9.5]), - HyperRectangle{2,Float32}(Float32[2.6, 45.75], Float32[0.8, 9.5]), - HyperRectangle{2,Float32}(Float32[3.6, 65.75], Float32[0.8, 9.5]), - HyperRectangle{2,Float32}(Float32[4.6, 85.75], Float32[0.8, 9.5]), + poly = [ + FRect2D(Float32[0.6, 5.75], Float32[0.8, 9.5]), + FRect2D(Float32[1.6, 25.75], Float32[0.8, 9.5]), + FRect2D(Float32[2.6, 45.75], Float32[0.8, 9.5]), + FRect2D(Float32[3.6, 65.75], Float32[0.8, 9.5]), + FRect2D(Float32[4.6, 85.75], Float32[0.8, 9.5]), ] @test plts[3].plots[1][1][] == poly @@ -102,7 +102,7 @@ end meshes = plts[3].plots[1][1][] @testset for (i, mesh) in enumerate(meshes) @test mesh isa AbstractPlotting.AbstractMesh - vertices = map(Point2f0, mesh.vertices) + vertices = map(Point2f0, mesh.position) @test vertices ≈ notch_boxes[i] end end