Adjust heatmap_edges for polar heatmaps
This commit is contained in:
parent
9b174084f7
commit
2594b577d7
@ -1579,7 +1579,7 @@ function gr_add_series(sp, series)
|
||||
dmin, dmax = GR.gr3.volume(y.v, 0)
|
||||
elseif st === :heatmap
|
||||
# `z` is already transposed, so we need to reverse before passing its size.
|
||||
x, y = heatmap_edges(x, xscale, y, yscale, reverse(size(z)))
|
||||
x, y = heatmap_edges(x, xscale, y, yscale, reverse(size(z)), ispolar(series))
|
||||
gr_draw_heatmap(series, x, y, z, clims)
|
||||
elseif st === :image
|
||||
gr_draw_image(series, x, y, z, clims)
|
||||
|
||||
14
src/utils.jl
14
src/utils.jl
@ -212,24 +212,24 @@ createSegments(z) = collect(repeat(reshape(z,1,:),2,1))[2:end]
|
||||
|
||||
sortedkeys(plotattributes::Dict) = sort(collect(keys(plotattributes)))
|
||||
|
||||
function _heatmap_edges(v::AVec, isedges::Bool = false)
|
||||
length(v) == 1 && return v[1] .+ [-0.5, 0.5]
|
||||
function _heatmap_edges(v::AVec, isedges::Bool = false, ispolar::Bool = false)
|
||||
length(v) == 1 && return v[1] .+ [ispolar ? max(-v[1], -0.5) : -0.5, 0.5]
|
||||
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_min = ispolar ? min(v[1], (v[2] - v[1]) / 2) : (v[2] - v[1]) / 2
|
||||
extra_max = (v[end] - v[end - 1]) / 2
|
||||
vcat(vmin-extra_min, 0.5 * (v[1:end-1] + v[2:end]), vmax+extra_max)
|
||||
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, ispolar::Bool = false)
|
||||
f, invf = RecipesPipeline.scale_func(scale), RecipesPipeline.inverse_scale_func(scale)
|
||||
map(invf, _heatmap_edges(map(f,v), isedges))
|
||||
map(invf, _heatmap_edges(map(f,v), isedges, ispolar))
|
||||
end
|
||||
|
||||
function heatmap_edges(x::AVec, xscale::Symbol, y::AVec, yscale::Symbol, z_size::Tuple{Int, Int})
|
||||
function heatmap_edges(x::AVec, xscale::Symbol, y::AVec, yscale::Symbol, z_size::Tuple{Int, Int}, ispolar::Bool = false)
|
||||
nx, ny = length(x), length(y)
|
||||
# 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.
|
||||
@ -241,7 +241,7 @@ function heatmap_edges(x::AVec, xscale::Symbol, y::AVec, yscale::Symbol, z_size:
|
||||
or `size(z) == (length(y)+1, length(x)+1))` (x & y define edges).""")
|
||||
end
|
||||
x, y = heatmap_edges(x, xscale, isedges),
|
||||
heatmap_edges(y, yscale, isedges)
|
||||
heatmap_edges(y, yscale, isedges, ispolar) # special handle for `r` in polar plots
|
||||
return x, y
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user