working on args
This commit is contained in:
parent
b23f968d57
commit
f632f2f39e
67
src/args.jl
67
src/args.jl
@ -300,7 +300,10 @@ wraptuple(x) = (x,)
|
||||
|
||||
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
|
||||
function processAxisArg(d::Dict, axisletter::AbstractString, arg)
|
||||
if isa(arg, Symbol)
|
||||
T = typeof(arg)
|
||||
delete!(d, symbol(axisletter * "axis"))
|
||||
|
||||
if T <: Symbol
|
||||
|
||||
# xscale/yscale
|
||||
if haskey(_scaleAliases, arg)
|
||||
@ -316,40 +319,39 @@ function processAxisArg(d::Dict, axisletter::AbstractString, arg)
|
||||
end
|
||||
|
||||
# xlims/ylims
|
||||
elseif (arg <: Tuple || arg <: AVec) && length(arg) == 2
|
||||
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
||||
d[symbol(axisletter * "lims")] = arg
|
||||
|
||||
# xticks/yticks
|
||||
elseif arg <: AVec
|
||||
elseif T <: AVec
|
||||
d[symbol(axisletter * "ticks")] = arg
|
||||
|
||||
else
|
||||
warn("Skipped $(axisletter)axis arg $arg. Unhandled type $(typeof(arg))")
|
||||
warn("Skipped $(axisletter)axis arg $arg. Unhandled type $T")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function processLineArg(d::Dict, arg)
|
||||
if isa(arg, Symbol)
|
||||
T = typeof(arg)
|
||||
delete!(d, :line)
|
||||
|
||||
if T <: Symbol
|
||||
|
||||
arg = get(_typeAliases, arg, arg)
|
||||
arg = get(_styleAliases, arg, arg)
|
||||
|
||||
# linetype
|
||||
if haskey(_typeAliases, arg)
|
||||
arg = _typeAliases[arg]
|
||||
end
|
||||
if arg in _allTypes
|
||||
d[:linetype] = arg
|
||||
end
|
||||
|
||||
# linestyle
|
||||
if haskey(_styleAliases, arg)
|
||||
arg = _styleAliases[arg]
|
||||
end
|
||||
if arg in _allStyles
|
||||
elseif arg in _allStyles
|
||||
d[:linestyle] = arg
|
||||
else
|
||||
warn("Skipped line arg $arg. Unknown symbol.")
|
||||
end
|
||||
|
||||
# linewidth
|
||||
elseif arg <: Real
|
||||
elseif T <: Real
|
||||
d[:linewidth] = arg
|
||||
|
||||
else
|
||||
@ -358,7 +360,7 @@ function processLineArg(d::Dict, arg)
|
||||
c = colorscheme(arg)
|
||||
d[:color] = c
|
||||
catch
|
||||
warn("Skipped line arg $arg. Unhandled type $(typeof(arg))")
|
||||
warn("Skipped line arg $arg. Unhandled type $T.")
|
||||
end
|
||||
|
||||
end
|
||||
@ -366,30 +368,31 @@ end
|
||||
|
||||
|
||||
function processMarkerArg(d::Dict, arg)
|
||||
if isa(arg, Symbol)
|
||||
T = typeof(arg)
|
||||
delete!(d, :marker)
|
||||
|
||||
if T <: Symbol
|
||||
|
||||
arg = get(_markerAliases, arg, arg)
|
||||
|
||||
# shape
|
||||
if haskey(_markerAliases, arg)
|
||||
arg = _markerAliases[arg]
|
||||
end
|
||||
if arg in _allMarkers
|
||||
d[:marker] = arg
|
||||
end
|
||||
|
||||
# linestyle
|
||||
if haskey(_styleAliases, arg)
|
||||
arg = _styleAliases[arg]
|
||||
end
|
||||
if arg in _allStyles
|
||||
d[:linestyle] = arg
|
||||
elseif arg != :match
|
||||
warn("Skipped marker arg $arg. Unknown symbol.")
|
||||
end
|
||||
|
||||
# markersize
|
||||
elseif arg <: Real
|
||||
elseif T <: Real
|
||||
d[:markersize] = arg
|
||||
|
||||
else
|
||||
warn("Skipped line arg $arg. Unhandled type $(typeof(arg))")
|
||||
|
||||
try
|
||||
c = colorscheme(arg)
|
||||
d[:markercolor] = c
|
||||
catch
|
||||
warn("Skipped marker arg $arg. Unhandled type $T.")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -95,8 +95,8 @@ const _gradients = Dict(
|
||||
:blues => [colorant"lightblue", colorant"darkblue"],
|
||||
:reds => [colorant"lightpink", colorant"darkred"],
|
||||
:greens => [colorant"lightgreen", colorant"darkgreen"],
|
||||
:redsblues => [colorant"darkred", RGB(0.9,0.9,0.9), colorant"darkblue"]
|
||||
:bluesreds => [colorant"darkblue", RGB(0.9,0.9,0.9), colorant"darkred"]
|
||||
:redsblues => [colorant"darkred", RGB(0.9,0.9,0.9), colorant"darkblue"],
|
||||
:bluesreds => [colorant"darkblue", RGB(0.9,0.9,0.9), colorant"darkred"],
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------
|
||||
@ -169,9 +169,10 @@ getColor(scheme::ColorFunction, z::Real, idx::Int) = scheme.f(z, idx)
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
"Wraps a vector of colors... may be Symbol/String or a Colorant"
|
||||
immutable ColorVector{V<:AbstractVector} <: ColorScheme
|
||||
v::V
|
||||
"Wraps a vector of colors... may be vector of Symbol/String/Colorant"
|
||||
immutable ColorVector <: ColorScheme
|
||||
v::Vector{Colorant}
|
||||
ColorVector(v::AVec) = convertColor(v)
|
||||
end
|
||||
|
||||
typealias CVec ColorVector
|
||||
|
||||
@ -46,6 +46,7 @@ function plot(args...; kw...)
|
||||
pkg = backend()
|
||||
d = Dict(kw)
|
||||
preprocessArgs!(d)
|
||||
for k in sort(collect(keys(d))); println(); @printf("%14s: ", k); println(d[k], "\n"); end
|
||||
|
||||
# # ensure we're passing in an RGB
|
||||
# if haskey(d, :background_color)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user