From 9e2264c841afa0371e074012a51eabfa3392d9c4 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 18 Feb 2018 22:49:27 +0100 Subject: [PATCH] consider fillrange in step recipes --- src/recipes.jl | 29 +++++++++++++++++++++++++++-- src/utils.jl | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 8c669a78..a94f5ec4 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -140,11 +140,32 @@ function make_steps(x, y, st) newx, newy end +make_steps(x, st) = x +function make_steps(x::AbstractArray, st) + n = length(x) + n == 0 && return zeros(0) + newx = zeros(2n - 1) + for i in 1:n + idx = 2i - 1 + newx[idx] = x[i] + if i > 1 + newx[idx - 1] = x[st == :pre ? i : i - 1] + end + end + return newx +end +make_steps(t::Tuple, st) = Tuple(make_steps(ti, st) for ti in t) + + # create a path from steps @recipe function f(::Type{Val{:steppre}}, x, y, z) - plotattributes[:x], plotattributes[:y] = make_steps(x, y, :steppre) + plotattributes[:x] = make_steps(x, :post) + plotattributes[:y] = make_steps(y, :pre) seriestype := :path + # handle fillrange + plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre) + # create a secondary series for the markers if plotattributes[:markershape] != :none @series begin @@ -163,9 +184,13 @@ end # create a path from steps @recipe function f(::Type{Val{:steppost}}, x, y, z) - plotattributes[:x], plotattributes[:y] = make_steps(x, y, :steppost) + plotattributes[:x] = make_steps(x, :pre) + plotattributes[:y] = make_steps(y, :post) seriestype := :path + # handle fillrange + plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post) + # create a secondary series for the markers if plotattributes[:markershape] != :none @series begin diff --git a/src/utils.jl b/src/utils.jl index 0600821e..3544ead9 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1051,7 +1051,7 @@ guidefont(ax::Axis) = font( # --------------------------------------------------------------- # converts unicode scientific notation unsupported by pgfplots and gr -# into a format that works +# into a format that works function convert_sci_unicode(label::AbstractString) unicode_dict = Dict(