use drawimage for heatmap

This commit is contained in:
Thomas Breloff 2016-10-11 10:32:51 -04:00
parent 837c0c06ed
commit 77fbf3eb51

View File

@ -817,18 +817,18 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
elseif st == :heatmap elseif st == :heatmap
zmin, zmax = gr_lims(zaxis, true) zmin, zmax = gr_lims(zaxis, true)
data = (float(z) - zmin) / (zmax - zmin)
clims = sp[:clims] clims = sp[:clims]
if is_2tuple(clims) if is_2tuple(clims)
isfinite(clims[1]) && (zmin = clims[1]) isfinite(clims[1]) && (zmin = clims[1])
isfinite(clims[2]) && (zmax = clims[2]) isfinite(clims[2]) && (zmax = clims[2])
end end
data = [if zmin<=d<=zmax 1000 + d * 255 else 0 end for d in data] grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad()
data = round(Int32, data) colors = [grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)] for zi=z]
xmin, xmax = gr_lims(xaxis, false) rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 +
ymin, ymax = gr_lims(yaxis, false) round(Int, blue(c) * 255) << 16 +
width, height = length(x), length(y) round(Int, green(c) * 255) << 8 +
GR.cellarray(xmin, xmax, ymin, ymax, width, height, data) round(Int, red(c) * 255) ), colors)
GR.drawimage(xmin, xmax, ymin, ymax, length(x), length(y), rgba)
cmap && gr_colorbar(sp) cmap && gr_colorbar(sp)
elseif st in (:path3d, :scatter3d) elseif st in (:path3d, :scatter3d)