Skip to content

Commit

Permalink
support scale in get_...color
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Nov 27, 2022
1 parent ce9c8ed commit ca4b721
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,34 @@ for comp in (:line, :fill, :marker)

@eval begin
# defines `get_linecolor`, `get_fillcolor` and `get_markercolor` <- for grep
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1)
function $get_compcolor(series, cmin::Real, cmax::Real, i::Integer = 1, s::Symbol = :identity)
c = series[$Symbol($compcolor)] # series[:linecolor], series[:fillcolor], series[:markercolor]
z = series[$Symbol($comp_z)] # series[:line_z], series[:fill_z], series[:marker_z]
if z === nothing
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
else
get(get_gradient(c), z[i], (cmin, cmax))
grad = get_gradient(c)
if s === :identity
get(grad, z[i], (cmin, cmax))
else
base = _logScaleBases[s]
get(grad, log(base, z[i]), (log(base, cmin), log(base, cmax)))
end
end
end

$get_compcolor(series, clims::Tuple{<:Number,<:Number}, i::Int = 1) =
$get_compcolor(series, clims[1], clims[2], i)

function $get_compcolor(series, i::Int = 1)
function $get_compcolor(series, i::Integer = 1, s::Symbol = :identity)
if series[$Symbol($comp_z)] === nothing
$get_compcolor(series, 0, 1, i)
$get_compcolor(series, 0, 1, i, s)
else
$get_compcolor(series, get_clims(series[:subplot]), i)
$get_compcolor(series, get_clims(series[:subplot]), i, s)
end
end

$get_compalpha(series, i::Int = 1) = _cycle(series[$Symbol($compalpha)], i)
$get_compcolor(series, clims::NTuple{2,<:Number}, args...) =
$get_compcolor(series, clims[1], clims[2], args...)

$get_compalpha(series, i::Integer = 1) = _cycle(series[$Symbol($compalpha)], i)
end
end

Expand Down

0 comments on commit ca4b721

Please sign in to comment.