diff --git a/src/recipes.jl b/src/recipes.jl index 91bd721b..3b1703b8 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -122,11 +122,9 @@ 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]) - newy = repeat(Float64[1, 2, NaN], n) x := newx - y := newy + y := y seriestype := :straightline () end @@ -145,9 +143,9 @@ end @deps hspan shape @recipe function f(::Type{Val{:vspan}}, x, y, z) - 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) + n = div(length(x), 2) + newx = vcat([[x[2i - 1], x[2i - 1], x[2i], x[2i], NaN] for i = 1:n]...) + newy = repeat([-Inf, Inf, Inf, -Inf, NaN], outer=div(length(x),2)) linewidth --> 0 x := newx y := newy diff --git a/src/shorthands.jl b/src/shorthands.jl index 0311e5d3..1417cc7d 100644 --- a/src/shorthands.jl +++ b/src/shorthands.jl @@ -199,9 +199,9 @@ julia> vline([-1,0,2]) ``` """ @shorthands vline -vline(x; kw...) = plot(x, []; kw..., seriestype=:vline) -vline!(x; kw...) = plot!(x, []; kw..., seriestype=:vline) -vline!(plt, x; kw...) = plot!(plt, x, []; kw..., seriestype=:vline) +vline(x; kw...) = plot(x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) +vline!(x; kw...) = plot!(x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) +vline!(plt, x; kw...) = plot!(plt, x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) """ hspan(y) @@ -232,6 +232,9 @@ julia> vspan(1:6) ``` """ @shorthands vspan +vspan(x; kw...) = plot(x, []; kw..., seriestype=:vspan) +vspan!(x; kw...) = plot!(x, []; kw..., seriestype=:vspan) +vspan!(plt, x; kw...) = plot!(plt, x, []; kw..., seriestype=:vspan) """ ohlc(x,y::Vector{OHLC})