isedges is now an arguement and not a keyword anymore
This commit is contained in:
parent
a728ed9a60
commit
686ab1b51f
18
src/utils.jl
18
src/utils.jl
@ -344,7 +344,9 @@ const _scale_base = Dict{Symbol, Real}(
|
||||
|
||||
function _heatmap_edges(v::AVec, isedges::Bool = false)
|
||||
length(v) == 1 && return v[1] .+ [-0.5, 0.5]
|
||||
if isedges return v end
|
||||
if isedges return v end
|
||||
# `isedges = true` means that v is a vector which already describes edges
|
||||
# and does not need to be extended.
|
||||
vmin, vmax = ignorenan_extrema(v)
|
||||
extra_min = (v[2] - v[1]) / 2
|
||||
extra_max = (v[end] - v[end - 1]) / 2
|
||||
@ -352,24 +354,24 @@ function _heatmap_edges(v::AVec, isedges::Bool = false)
|
||||
end
|
||||
|
||||
"create an (n+1) list of the outsides of heatmap rectangles"
|
||||
function heatmap_edges(v::AVec, scale::Symbol = :identity; isedges::Bool = false)
|
||||
function heatmap_edges(v::AVec, scale::Symbol = :identity, isedges::Bool = false)
|
||||
f, invf = scalefunc(scale), invscalefunc(scale)
|
||||
map(invf, _heatmap_edges(map(f,v), isedges))
|
||||
end
|
||||
|
||||
function heatmap_edges(x::AVec, xscale::Symbol, y::AVec, yscale::Symbol, z_size::Tuple{Int, Int})
|
||||
nx, ny = length(x), length(y)
|
||||
# use_midpoints = z_size == (ny, nx) # This fails some tests, but would actually be
|
||||
# ismidpoints = z_size == (ny, nx) # This fails some tests, but would actually be
|
||||
# the correct check, since (4, 3) != (3, 4) and a missleading plot is produced.
|
||||
use_midpoints = prod(z_size) == (ny * nx)
|
||||
use_edges = z_size == (ny - 1, nx - 1)
|
||||
if !use_midpoints && !use_edges
|
||||
ismidpoints = prod(z_size) == (ny * nx)
|
||||
isedges = z_size == (ny - 1, nx - 1)
|
||||
if !ismidpoints && !isedges
|
||||
error("""Length of x & y does not match the size of z.
|
||||
Must be either `size(z) == (length(y), length(x))` (x & y define midpoints)
|
||||
or `size(z) == (length(y)+1, length(x)+1))` (x & y define edges).""")
|
||||
end
|
||||
x, y = heatmap_edges(x, xscale; isedges = use_edges),
|
||||
heatmap_edges(y, yscale; isedges = use_edges)
|
||||
x, y = heatmap_edges(x, xscale, isedges),
|
||||
heatmap_edges(y, yscale, isedges)
|
||||
return x, y
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user