allow false for color; properly expand extrema for tuple fillrange; make_fillrange_from_ribbon

This commit is contained in:
Thomas Breloff 2016-06-08 09:51:27 -04:00
parent 4be2304ec1
commit 91ec0ad077
5 changed files with 29 additions and 5 deletions

View File

@ -819,7 +819,7 @@ end
function color_or_nothing!(d::KW, k::Symbol)
v = d[k]
d[k] = if v == nothing
d[k] = if v == nothing || v == false
colorscheme(RGBA(0,0,0,0))
else
v

View File

@ -170,7 +170,14 @@ function expand_extrema!(sp::Subplot, d::KW)
fr = 0.0
end
if fr != nothing
expand_extrema!(sp.attr[vert ? :yaxis : :xaxis], fr)
axis = sp.attr[vert ? :yaxis : :xaxis]
if typeof(fr) <: Tuple
for fri in fr
expand_extrema!(axis, fri)
end
else
expand_extrema!(axis, fr)
end
end
# expand for bar_width

View File

@ -255,8 +255,7 @@ function _plot!(plt::Plot, d::KW, args...)
# convert a ribbon into a fillrange
if get(kw, :ribbon, nothing) != nothing
rib = kw[:ribbon]
kw[:fillrange] = (kw[:y] - rib, kw[:y] + rib)
make_fillrange_from_ribbon(kw)
end
# add the plot index

View File

@ -62,9 +62,11 @@ function convertToAnyVector(v::AVec, d::KW)
end
end
convertToAnyVector(t::Tuple, d::KW) = Any[t], nothing
function convertToAnyVector(args...)
error("No recipes could handle the argument types: $(map(typeof, args[1:end-1]))")
error("In convertToAnyVector, could not handle the argument types: $(map(typeof, args[1:end-1]))")
end
# --------------------------------------------------------------------

View File

@ -310,7 +310,23 @@ function ok(x::Number, y::Number, z::Number = 0)
end
ok(tup::Tuple) = ok(tup...)
# compute one side of a fill range from a ribbon
function make_fillrange_side(y, rib)
frs = zeros(length(y))
for (i, (yi, ri)) in enumerate(zip(y, cycle(rib)))
frs[i] = yi + ri
end
frs
end
# turn a ribbon into a fillrange
function make_fillrange_from_ribbon(kw::KW)
y, rib = kw[:y], kw[:ribbon]
rib = wraptuple(rib)
rib1, rib2 = -first(rib), last(rib)
kw[:ribbon] = nothing
kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2)
end
# ---------------------------------------------------------------