From 7c5b7b09c287c4e7e72650c3f125754e15445768 Mon Sep 17 00:00:00 2001 From: Lukas Hauertmann Date: Mon, 4 Nov 2019 21:29:35 +0100 Subject: [PATCH] Add keyword `isedges::Bool = false` to function `heatmap_edges` Add the keyword `isedges::Bool` to the functions `heatmap_edges` and `_heatmap_edges`. Default is `false`. If `true`, the functions treat the given vector `v` as edges and not as midpoints. --- src/utils.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 0c2b4b80..bd127f6c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -342,8 +342,9 @@ const _scale_base = Dict{Symbol, Real}( :ln => ℯ, ) -function _heatmap_edges(v::AVec) +function _heatmap_edges(v::AVec, isedges::Bool = false) length(v) == 1 && return v[1] .+ [-0.5, 0.5] + if isedges return v end vmin, vmax = ignorenan_extrema(v) extra_min = (v[2] - v[1]) / 2 extra_max = (v[end] - v[end - 1]) / 2 @@ -351,9 +352,9 @@ function _heatmap_edges(v::AVec) end "create an (n+1) list of the outsides of heatmap rectangles" -function heatmap_edges(v::AVec, scale::Symbol = :identity) +function heatmap_edges(v::AVec, scale::Symbol = :identity; isedges::Bool = false) f, invf = scalefunc(scale), invscalefunc(scale) - map(invf, _heatmap_edges(map(f,v))) + map(invf, _heatmap_edges(map(f,v), isedges)) end function convert_to_polar(theta, r, r_extrema = ignorenan_extrema(r))