Merge pull request #1400 from daschw/step-ribbon
consider fillrange in step recipes (fix #1393)
This commit is contained in:
commit
a118d73871
@ -124,27 +124,32 @@ end
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# steps
|
# steps
|
||||||
|
|
||||||
function make_steps(x, y, st)
|
make_steps(x, st) = x
|
||||||
|
function make_steps(x::AbstractArray, st)
|
||||||
n = length(x)
|
n = length(x)
|
||||||
n == 0 && return zeros(0),zeros(0)
|
n == 0 && return zeros(0)
|
||||||
newx, newy = zeros(2n-1), zeros(2n-1)
|
newx = zeros(2n - 1)
|
||||||
for i=1:n
|
for i in 1:n
|
||||||
idx = 2i-1
|
idx = 2i - 1
|
||||||
newx[idx] = x[i]
|
newx[idx] = x[i]
|
||||||
newy[idx] = y[i]
|
|
||||||
if i > 1
|
if i > 1
|
||||||
newx[idx-1] = x[st == :steppre ? i-1 : i]
|
newx[idx - 1] = x[st == :pre ? i : i - 1]
|
||||||
newy[idx-1] = y[st == :steppre ? i : i-1]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
newx, newy
|
return newx
|
||||||
end
|
end
|
||||||
|
make_steps(t::Tuple, st) = Tuple(make_steps(ti, st) for ti in t)
|
||||||
|
|
||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
@recipe function f(::Type{Val{:steppre}}, x, y, z)
|
@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
|
seriestype := :path
|
||||||
|
|
||||||
|
# handle fillrange
|
||||||
|
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre)
|
||||||
|
|
||||||
# create a secondary series for the markers
|
# create a secondary series for the markers
|
||||||
if plotattributes[:markershape] != :none
|
if plotattributes[:markershape] != :none
|
||||||
@series begin
|
@series begin
|
||||||
@ -163,9 +168,13 @@ end
|
|||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
@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
|
seriestype := :path
|
||||||
|
|
||||||
|
# handle fillrange
|
||||||
|
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post)
|
||||||
|
|
||||||
# create a secondary series for the markers
|
# create a secondary series for the markers
|
||||||
if plotattributes[:markershape] != :none
|
if plotattributes[:markershape] != :none
|
||||||
@series begin
|
@series begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user