From c041112b9c80b0725020a2d228cc29b67d891a2d Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 17 Sep 2020 10:24:47 +0200 Subject: [PATCH] fix vline, vspan with dates --- src/recipes.jl | 8 ++++---- test/integration_dates.jl | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index dd8d2dc5..24ab0075 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -122,8 +122,8 @@ end @deps hline straightline @recipe function f(::Type{Val{:vline}}, x, y, z) - n = length(x) - newx = vec(Float64[xi for i = 1:3, xi in x]) + n = length(y) + newx = vec(Float64[yi for i = 1:3, yi in y]) x := newx y := repeat(Float64[1, 2, NaN], n) seriestype := :straightline @@ -144,8 +144,8 @@ end @deps hspan shape @recipe function f(::Type{Val{:vspan}}, x, y, z) - n = div(length(x), 2) - newx = vcat([[x[2i - 1], x[2i - 1], x[2i], x[2i], NaN] for i = 1:n]...) + n = div(length(y), 2) + newx = vcat([[y[2i - 1], y[2i - 1], y[2i], y[2i], NaN] for i = 1:n]...) newy = repeat([-Inf, Inf, Inf, -Inf, NaN], outer = n) linewidth --> 0 x := newx diff --git a/test/integration_dates.jl b/test/integration_dates.jl index b8c300ee..6b7e9943 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -6,10 +6,11 @@ using Plots, Test, Dates rx=[x[3],x[5]] - ref_ylims = (y[begin], y[end]) - ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) p = plot(x,y, widen = false) vspan!(p, rx, label="", alpha=0.2) + + ref_ylims = (y[begin], y[end]) + ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims end # testset