From eae40922fe0bf566dc3e175b114b2966b9a830c6 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 17 Sep 2020 10:42:13 +0200 Subject: [PATCH] add limit tests for vline and vspan --- src/recipes.jl | 2 +- test/test_recipes.jl | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 24ab0075..5760a6c1 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -133,7 +133,7 @@ end @recipe function f(::Type{Val{:hspan}}, x, y, z) n = div(length(y), 2) - newx = repeat([-Inf, Inf, Inf, -Inf, NaN], outer = n) + newx = repeat([1, 2, 2, 1, NaN], outer = n) newy = vcat([[y[2i - 1], y[2i - 1], y[2i], y[2i], NaN] for i = 1:n]...) linewidth --> 0 x := newx diff --git a/test/test_recipes.jl b/test/test_recipes.jl index b1f34351..f03a7d2a 100644 --- a/test/test_recipes.jl +++ b/test/test_recipes.jl @@ -4,3 +4,21 @@ using Plots, Test lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2))) @test length(pl.series_list) == 4 end # testset + +@testset "vline, vspan" begin + vl = vline([1], widen = false) + @test Plots.xlims(vl) == (1,2) + @test Plots.ylims(vl) == (1,2) + vl = vline([1], xlims=(0,2), widen = false) + @test Plots.xlims(vl) == (0,2) + vl = vline([1], ylims=(-3,5), widen = false) + @test Plots.ylims(vl) == (-3,5) + + vsp = vspan([1,3], widen = false) + @test Plots.xlims(vsp) == (1,3) + @test Plots.ylims(vsp) == (0,1) # TODO: might be problematic on log-scales + vsp = vspan([1,3], xlims=(-2,5), widen = false) + @test Plots.xlims(vsp) == (-2,5) + vsp = vspan([1,3], ylims=(-2,5), widen = false) + @test Plots.ylims(vsp) == (-2,5) +end # testset