Merge pull request #2760 from daschw/gr-heatmap

improve nonuniform heatmap performance on GR
This commit is contained in:
Daniel Schwabeneder 2020-06-05 19:55:16 +02:00 committed by GitHub
commit f2d7d394bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -943,6 +943,12 @@ function is_equally_spaced(v)
all(d .≈ d[1]) all(d .≈ d[1])
end end
remap(x, lo, hi) = (x - lo) / (hi - lo)
function get_z_normalized(z, clims...)
isnan(z) && return 256 / 255
return remap(clamp(z, clims...), clims...)
end
function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
_update_min_padding!(sp) _update_min_padding!(sp)
@ -1712,8 +1718,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if something(series[:fillalpha],1) < 1 if something(series[:fillalpha],1) < 1
@warn "GR: transparency not supported in non-uniform heatmaps. Alpha values ignored." @warn "GR: transparency not supported in non-uniform heatmaps. Alpha values ignored."
end end
colors = get(fillgrad, z, clims) z_normalized = get_z_normalized.(z, zmin, zmax)
z_normalized = map(c -> c == invisible() ? 256/255 : PlotUtils.getinverse(fillgrad, c), colors)
rgba = Int32[round(Int32, 1000 + _i * 255) for _i in z_normalized] rgba = Int32[round(Int32, 1000 + _i * 255) for _i in z_normalized]
GR.nonuniformcellarray(x, y, w, h, rgba) GR.nonuniformcellarray(x, y, w, h, rgba)
end end