allow transparency in heatmaps

This commit is contained in:
Daniel Schwabeneder 2018-01-08 12:50:46 +01:00
parent 1949b6fe0f
commit f6ed3fbb76
3 changed files with 6 additions and 5 deletions

View File

@ -1082,7 +1082,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
zmin, zmax = clims zmin, zmax = clims
GR.setspace(zmin, zmax, 0, 90) GR.setspace(zmin, zmax, 0, 90)
grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad() grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad()
colors = [grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)] for zi=z] colors = [plot_color(grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)], series[:fillalpha]) for zi=z]
rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 + rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 +
round(Int, blue(c) * 255) << 16 + round(Int, blue(c) * 255) << 16 +
round(Int, green(c) * 255) << 8 + round(Int, green(c) * 255) << 8 +
@ -1207,7 +1207,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if cmap && st != :contour # special colorbar with steps is drawn for contours if cmap && st != :contour # special colorbar with steps is drawn for contours
gr_set_line(1, :solid, yaxis[:foreground_color_axis]) gr_set_line(1, :solid, yaxis[:foreground_color_axis])
GR.settransparency(1) GR.settransparency(1)
gr_colorbar(sp, clims) gr_colorbar(sp, clims, series[:fillalpha])
end end
GR.restorestate() GR.restorestate()

View File

@ -430,7 +430,7 @@ end
function plotly_colorscale(grad::ColorGradient, α) function plotly_colorscale(grad::ColorGradient, α)
[[grad.values[i], rgb_string(grad.colors[i])] for i in 1:length(grad.colors)] [[grad.values[i], rgba_string(plot_color(grad.colors[i], α))] for i in 1:length(grad.colors)]
end end
plotly_colorscale(c, α) = plotly_colorscale(cgrad(alpha=α), α) plotly_colorscale(c, α) = plotly_colorscale(cgrad(alpha=α), α)
# plotly_colorscale(c, alpha = nothing) = plotly_colorscale(cgrad(), alpha) # plotly_colorscale(c, alpha = nothing) = plotly_colorscale(cgrad(), alpha)

View File

@ -768,6 +768,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
label = series[:label], label = series[:label],
zorder = series[:series_plotindex], zorder = series[:series_plotindex],
cmap = py_fillcolormap(series), cmap = py_fillcolormap(series),
alpha = series[:fillalpha],
# edgecolors = (series[:linewidth] > 0 ? py_linecolor(series) : "face"), # edgecolors = (series[:linewidth] > 0 ? py_linecolor(series) : "face"),
extrakw... extrakw...
) )