From f56d944870d13ef56c14df74f99331b9639d22de Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 28 Mar 2018 11:32:23 +0200 Subject: [PATCH] hspan and vspan recipes --- src/Plots.jl | 2 ++ src/recipes.jl | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Plots.jl b/src/Plots.jl index 222270cb..f1026810 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -187,6 +187,8 @@ include("output.jl") @shorthands sticks @shorthands hline @shorthands vline +@shorthands hspan +@shorthands vspan @shorthands ohlc @shorthands contour @shorthands contourf diff --git a/src/recipes.jl b/src/recipes.jl index bfe7d0b4..099d9b38 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -100,6 +100,30 @@ end end @deps vline straightline +@recipe function f(::Type{Val{:hspan}}, x, y, z) + n = div(length(y), 2) + newx = repeat([-Inf, Inf, Inf, -Inf, NaN], outer = n) + newy = vcat([[y[2i-1], y[2i-1], y[2i], y[2i], NaN] for i in 1:n]...) + linewidth --> 0 + x := newx + y := newy + seriestype := :shape + () +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 in 1:n]...) + newy = repeat([-Inf, Inf, Inf, -Inf, NaN], outer = n) + linewidth --> 0 + x := newx + y := newy + seriestype := :shape + () +end +@deps vspan shape + # --------------------------------------------------------------------------- # path and scatter