working on args
This commit is contained in:
parent
70db97d576
commit
b6855b6fba
19
src/args.jl
19
src/args.jl
@ -301,8 +301,6 @@ wraptuple(x) = (x,)
|
|||||||
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
|
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
|
||||||
function processAxisArg(d::Dict, axisletter::AbstractString, arg)
|
function processAxisArg(d::Dict, axisletter::AbstractString, arg)
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
delete!(d, symbol(axisletter * "axis"))
|
|
||||||
|
|
||||||
if T <: Symbol
|
if T <: Symbol
|
||||||
|
|
||||||
arg = get(_scaleAliases, arg, arg)
|
arg = get(_scaleAliases, arg, arg)
|
||||||
@ -338,8 +336,6 @@ end
|
|||||||
|
|
||||||
function processLineArg(d::Dict, arg)
|
function processLineArg(d::Dict, arg)
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
delete!(d, :line)
|
|
||||||
|
|
||||||
if T <: Symbol
|
if T <: Symbol
|
||||||
|
|
||||||
arg = get(_typeAliases, arg, arg)
|
arg = get(_typeAliases, arg, arg)
|
||||||
@ -367,13 +363,13 @@ end
|
|||||||
|
|
||||||
function processMarkerArg(d::Dict, arg)
|
function processMarkerArg(d::Dict, arg)
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
delete!(d, :marker)
|
|
||||||
|
|
||||||
if T <: Symbol
|
if T <: Symbol
|
||||||
|
|
||||||
arg = get(_markerAliases, arg, arg)
|
arg = get(_markerAliases, arg, arg)
|
||||||
|
println(arg)
|
||||||
|
|
||||||
if arg in _allMarkers
|
if arg in _allMarkers
|
||||||
|
println("HERE ", arg)
|
||||||
d[:marker] = arg
|
d[:marker] = arg
|
||||||
elseif arg != :match && !handleColors!(d, arg, :markercolor)
|
elseif arg != :match && !handleColors!(d, arg, :markercolor)
|
||||||
warn("Skipped marker arg $arg. Unknown symbol.")
|
warn("Skipped marker arg $arg. Unknown symbol.")
|
||||||
@ -393,19 +389,28 @@ end
|
|||||||
function preprocessArgs!(d::Dict)
|
function preprocessArgs!(d::Dict)
|
||||||
replaceAliases!(d, _keyAliases)
|
replaceAliases!(d, _keyAliases)
|
||||||
|
|
||||||
|
# handle axis args
|
||||||
for axisletter in ("x", "y")
|
for axisletter in ("x", "y")
|
||||||
for arg in wraptuple(get(d, symbol(axisletter * "axis"), ()))
|
asym = symbol(axisletter * "axis")
|
||||||
|
for arg in wraptuple(get(d, asym, ()))
|
||||||
processAxisArg(d, axisletter, arg)
|
processAxisArg(d, axisletter, arg)
|
||||||
end
|
end
|
||||||
|
delete!(d, asym)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# handle line args
|
||||||
for arg in wraptuple(get(d, :line, ()))
|
for arg in wraptuple(get(d, :line, ()))
|
||||||
processLineArg(d, arg)
|
processLineArg(d, arg)
|
||||||
end
|
end
|
||||||
|
delete!(d, :line)
|
||||||
|
|
||||||
|
# handle marker args... default to ellipse if shape not set
|
||||||
for arg in wraptuple(get(d, :marker, ()))
|
for arg in wraptuple(get(d, :marker, ()))
|
||||||
processMarkerArg(d, arg)
|
processMarkerArg(d, arg)
|
||||||
end
|
end
|
||||||
|
if haskey(d, :marker) && typeof(d[:marker]) <: Tuple
|
||||||
|
d[:marker] = :ellipse
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@ -277,7 +277,8 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
# Should ensure from this side that colors which are the same are merged together
|
# Should ensure from this side that colors which are the same are merged together
|
||||||
|
|
||||||
push!(guide.labels, d[:label])
|
push!(guide.labels, d[:label])
|
||||||
push!(guide.colors, d[:marker] == :none ? first(d[:color]) : d[:markercolor])
|
# push!(guide.colors, d[:marker] == :none ? first(d[:color]) : d[:markercolor])
|
||||||
|
push!(guide.colors, getColor(d[d[:marker] == :none ? :color : :markercolor], 1))
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,7 +14,7 @@ function createGadflyAnnotation(d::Dict)
|
|||||||
shape = ohlcshape(x, y, d[:markersize])
|
shape = ohlcshape(x, y, d[:markersize])
|
||||||
d[:y] = Float64[z.open for z in y]
|
d[:y] = Float64[z.open for z in y]
|
||||||
d[:linetype] = :none
|
d[:linetype] = :none
|
||||||
return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(nothing), Gadfly.stroke(d[:color])))
|
return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(nothing), Gadfly.stroke(getColor(d[:color],1)))
|
||||||
|
|
||||||
elseif marker == :rect
|
elseif marker == :rect
|
||||||
shape = square(x, y, sz)
|
shape = square(x, y, sz)
|
||||||
@ -54,7 +54,7 @@ function createGadflyAnnotation(d::Dict)
|
|||||||
shape = Gadfly.circle(xs,ys,[sz])
|
shape = Gadfly.circle(xs,ys,[sz])
|
||||||
end
|
end
|
||||||
|
|
||||||
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(d[:markercolor]), Gadfly.stroke(colorant"white")))
|
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(getColorVector(d[:markercolor])), Gadfly.stroke(colorant"white")))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,7 @@ abstract ColorScheme
|
|||||||
|
|
||||||
getColor(scheme::ColorScheme, idx::Integer) = getColor(scheme, 0.0, idx)
|
getColor(scheme::ColorScheme, idx::Integer) = getColor(scheme, 0.0, idx)
|
||||||
getColor(scheme::ColorScheme, z::AbstractFloat) = getColor(scheme, z, 0)
|
getColor(scheme::ColorScheme, z::AbstractFloat) = getColor(scheme, z, 0)
|
||||||
|
getColorVector(scheme::ColorScheme) = [getColor(scheme, 0.0, 1)]
|
||||||
|
|
||||||
colorscheme(scheme::ColorScheme) = scheme
|
colorscheme(scheme::ColorScheme) = scheme
|
||||||
colorscheme(s::Symbol) = haskey(_gradients, s) ? ColorGradient(s) : ColorWrapper(convertColor(s))
|
colorscheme(s::Symbol) = haskey(_gradients, s) ? ColorGradient(s) : ColorWrapper(convertColor(s))
|
||||||
@ -144,6 +145,8 @@ function getColor(gradient::ColorGradient, z::Real, idx::Int)
|
|||||||
cs[end]
|
cs[end]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
getColorVector(gradient::ColorGradient) = [gradient.cs[1]]
|
||||||
|
|
||||||
function interpolate(c1::Colorant, c2::Colorant, w::Real)
|
function interpolate(c1::Colorant, c2::Colorant, w::Real)
|
||||||
lab1 = Lab(c1)
|
lab1 = Lab(c1)
|
||||||
lab2 = Lab(c2)
|
lab2 = Lab(c2)
|
||||||
@ -179,6 +182,7 @@ end
|
|||||||
typealias CVec ColorVector
|
typealias CVec ColorVector
|
||||||
|
|
||||||
getColor(scheme::ColorVector, z::Real, idx::Int) = convertColor(scheme.v[mod1(idx, length(scheme.v))])
|
getColor(scheme::ColorVector, z::Real, idx::Int) = convertColor(scheme.v[mod1(idx, length(scheme.v))])
|
||||||
|
getColorVector(scheme::ColorVector) = scheme.v
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user