Merge pull request #1092 from daschw/plotly-marker_z

fix marker_z for plotly
This commit is contained in:
Daniel Schwabeneder 2017-09-21 22:04:16 +02:00 committed by GitHub
commit 371f0a6a73

View File

@ -575,14 +575,18 @@ function plotly_series(plt::Plot, series::Series)
) )
# gotta hack this (for now?) since plotly can't handle rgba values inside the gradient # gotta hack this (for now?) since plotly can't handle rgba values inside the gradient
d_out[:marker][:color] = if series[:marker_z] == nothing if series[:marker_z] == nothing
rgba_string(series[:markercolor]) d_out[:marker][:color] = rgba_string(series[:markercolor])
else else
# grad = ColorGradient(series[:markercolor], alpha=series[:markeralpha]) # grad = ColorGradient(series[:markercolor], alpha=series[:markeralpha])
grad = as_gradient(series[:markercolor], series[:markeralpha]) # grad = as_gradient(series[:markercolor], series[:markeralpha])
zmin, zmax = ignorenan_extrema(series[:marker_z]) cmin, cmax = get_clims(sp)
zrange = zmax == zmin ? 1 : zmax - zmin # if all marker_z values are the same, plot all markers same color (avoids division by zero in next line) # zrange = zmax == zmin ? 1 : zmax - zmin # if all marker_z values are the same, plot all markers same color (avoids division by zero in next line)
[rgba_string(grad[(zi - zmin) / zrange]) for zi in series[:marker_z]] d_out[:marker][:color] = [clamp(zi, cmin, cmax) for zi in series[:marker_z]]
d_out[:marker][:cmin] = cmin
d_out[:marker][:cmax] = cmax
d_out[:marker][:colorscale] = plotly_colorscale(series[:markercolor], series[:markeralpha])
d_out[:marker][:showscale] = hascolorbar(sp)
end end
end end