add limit tests for vline and vspan

This commit is contained in:
Simon Christ 2020-09-17 10:42:13 +02:00
parent c041112b9c
commit eae40922fe
2 changed files with 19 additions and 1 deletions

View File

@ -133,7 +133,7 @@ end
@recipe function f(::Type{Val{:hspan}}, x, y, z) @recipe function f(::Type{Val{:hspan}}, x, y, z)
n = div(length(y), 2) 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]...) newy = vcat([[y[2i - 1], y[2i - 1], y[2i], y[2i], NaN] for i = 1:n]...)
linewidth --> 0 linewidth --> 0
x := newx x := newx

View File

@ -4,3 +4,21 @@ using Plots, Test
lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2))) lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2)))
@test length(pl.series_list) == 4 @test length(pl.series_list) == 4
end # testset 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