fix vline, vspan with dates
This commit is contained in:
parent
099817e083
commit
c041112b9c
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user