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
|
# 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)
|
||||||
if isa(arg, Symbol)
|
T = typeof(arg)
|
||||||
|
delete!(d, symbol(axisletter * "axis"))
|
||||||
|
|
||||||
|
if T <: Symbol
|
||||||
|
|
||||||
# xscale/yscale
|
# xscale/yscale
|
||||||
if haskey(_scaleAliases, arg)
|
if haskey(_scaleAliases, arg)
|
||||||
@ -316,40 +319,39 @@ function processAxisArg(d::Dict, axisletter::AbstractString, arg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# xlims/ylims
|
# xlims/ylims
|
||||||
elseif (arg <: Tuple || arg <: AVec) && length(arg) == 2
|
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
||||||
d[symbol(axisletter * "lims")] = arg
|
d[symbol(axisletter * "lims")] = arg
|
||||||
|
|
||||||
# xticks/yticks
|
# xticks/yticks
|
||||||
elseif arg <: AVec
|
elseif T <: AVec
|
||||||
d[symbol(axisletter * "ticks")] = arg
|
d[symbol(axisletter * "ticks")] = arg
|
||||||
|
|
||||||
else
|
else
|
||||||
warn("Skipped $(axisletter)axis arg $arg. Unhandled type $(typeof(arg))")
|
warn("Skipped $(axisletter)axis arg $arg. Unhandled type $T")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function processLineArg(d::Dict, arg)
|
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
|
# linetype
|
||||||
if haskey(_typeAliases, arg)
|
|
||||||
arg = _typeAliases[arg]
|
|
||||||
end
|
|
||||||
if arg in _allTypes
|
if arg in _allTypes
|
||||||
d[:linetype] = arg
|
d[:linetype] = arg
|
||||||
end
|
elseif arg in _allStyles
|
||||||
|
|
||||||
# linestyle
|
|
||||||
if haskey(_styleAliases, arg)
|
|
||||||
arg = _styleAliases[arg]
|
|
||||||
end
|
|
||||||
if arg in _allStyles
|
|
||||||
d[:linestyle] = arg
|
d[:linestyle] = arg
|
||||||
|
else
|
||||||
|
warn("Skipped line arg $arg. Unknown symbol.")
|
||||||
end
|
end
|
||||||
|
|
||||||
# linewidth
|
# linewidth
|
||||||
elseif arg <: Real
|
elseif T <: Real
|
||||||
d[:linewidth] = arg
|
d[:linewidth] = arg
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -358,7 +360,7 @@ function processLineArg(d::Dict, arg)
|
|||||||
c = colorscheme(arg)
|
c = colorscheme(arg)
|
||||||
d[:color] = c
|
d[:color] = c
|
||||||
catch
|
catch
|
||||||
warn("Skipped line arg $arg. Unhandled type $(typeof(arg))")
|
warn("Skipped line arg $arg. Unhandled type $T.")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -366,30 +368,31 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function processMarkerArg(d::Dict, arg)
|
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
|
if arg in _allMarkers
|
||||||
d[:marker] = arg
|
d[:marker] = arg
|
||||||
end
|
elseif arg != :match
|
||||||
|
warn("Skipped marker arg $arg. Unknown symbol.")
|
||||||
# linestyle
|
|
||||||
if haskey(_styleAliases, arg)
|
|
||||||
arg = _styleAliases[arg]
|
|
||||||
end
|
|
||||||
if arg in _allStyles
|
|
||||||
d[:linestyle] = arg
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# markersize
|
# markersize
|
||||||
elseif arg <: Real
|
elseif T <: Real
|
||||||
d[:markersize] = arg
|
d[:markersize] = arg
|
||||||
|
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@ -95,8 +95,8 @@ const _gradients = Dict(
|
|||||||
:blues => [colorant"lightblue", colorant"darkblue"],
|
:blues => [colorant"lightblue", colorant"darkblue"],
|
||||||
:reds => [colorant"lightpink", colorant"darkred"],
|
:reds => [colorant"lightpink", colorant"darkred"],
|
||||||
:greens => [colorant"lightgreen", colorant"darkgreen"],
|
:greens => [colorant"lightgreen", colorant"darkgreen"],
|
||||||
:redsblues => [colorant"darkred", RGB(0.9,0.9,0.9), colorant"darkblue"]
|
:redsblues => [colorant"darkred", RGB(0.9,0.9,0.9), colorant"darkblue"],
|
||||||
:bluesreds => [colorant"darkblue", RGB(0.9,0.9,0.9), colorant"darkred"]
|
: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"
|
"Wraps a vector of colors... may be vector of Symbol/String/Colorant"
|
||||||
immutable ColorVector{V<:AbstractVector} <: ColorScheme
|
immutable ColorVector <: ColorScheme
|
||||||
v::V
|
v::Vector{Colorant}
|
||||||
|
ColorVector(v::AVec) = convertColor(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
typealias CVec ColorVector
|
typealias CVec ColorVector
|
||||||
|
|||||||
@ -46,6 +46,7 @@ function plot(args...; kw...)
|
|||||||
pkg = backend()
|
pkg = backend()
|
||||||
d = Dict(kw)
|
d = Dict(kw)
|
||||||
preprocessArgs!(d)
|
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
|
# # ensure we're passing in an RGB
|
||||||
# if haskey(d, :background_color)
|
# if haskey(d, :background_color)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user