From 77fbf3eb513ec4f04fe06bb41ca641ad0f507701 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 11 Oct 2016 10:32:51 -0400 Subject: [PATCH] use drawimage for heatmap --- src/backends/gr.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 6f2706bd..7a12bae7 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -817,18 +817,18 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) elseif st == :heatmap zmin, zmax = gr_lims(zaxis, true) - data = (float(z) - zmin) / (zmax - zmin) clims = sp[:clims] if is_2tuple(clims) isfinite(clims[1]) && (zmin = clims[1]) isfinite(clims[2]) && (zmax = clims[2]) end - data = [if zmin<=d<=zmax 1000 + d * 255 else 0 end for d in data] - data = round(Int32, data) - xmin, xmax = gr_lims(xaxis, false) - ymin, ymax = gr_lims(yaxis, false) - width, height = length(x), length(y) - GR.cellarray(xmin, xmax, ymin, ymax, width, height, data) + grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad() + colors = [grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)] for zi=z] + rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 + + round(Int, blue(c) * 255) << 16 + + round(Int, green(c) * 255) << 8 + + round(Int, red(c) * 255) ), colors) + GR.drawimage(xmin, xmax, ymin, ymax, length(x), length(y), rgba) cmap && gr_colorbar(sp) elseif st in (:path3d, :scatter3d)