diff --git a/src/args.jl b/src/args.jl index 9bfed7cb..ebd2c2f7 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1532,7 +1532,7 @@ function _add_defaults!(d::KW, plt::Plot, sp::Subplot, commandIndex::Int) elseif d[:markerstrokecolor] == :auto getSeriesRGBColor(plot_color(d[:markercolor], d[:markeralpha]), sp, plotIndex) else - getSeriesRGBColor(plot_color(d[:markerstrokecolor], d[:markerstrokealpha]), sp, plotIndex) + getSeriesRGBColor.(d[:markerstrokecolor], sp, plotIndex) end # if marker_z, fill_z or line_z are set, ensure we have a gradient diff --git a/src/backends/gr.jl b/src/backends/gr.jl index b742eb15..76fd32b8 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -357,21 +357,15 @@ function gr_draw_markers(series::Series, x, y, msize, mz) # draw a filled in shape, slightly bigger, to estimate a stroke if series[:markerstrokewidth] > 0 - cfunc(_cycle(series[:markerstrokecolor], i)) #, series[:markerstrokealpha]) + cfunc(get_markerstrokecolor(series, i)) + gr_set_transparency(get_markerstrokealpha(series, i)) gr_draw_marker(x[i], y[i], msi + series[:markerstrokewidth], shape) end - # draw the shape - if mz == nothing - cfunc(_cycle(series[:markercolor], i)) #, series[:markeralpha]) - else - # pick a color from the pre-loaded gradient - ci = round(Int, 1000 + _cycle(mz, i) * 255) - cfuncind(ci) - gr_set_transparency(_gr_gradient_alpha[ci-999]) - end - # don't draw filled area if marker shape is 1D + # draw the shape - don't draw filled area if marker shape is 1D if !(shape in (:hline, :vline, :+, :x)) + cfunc(get_markercolor(series, i)) + gr_set_transparency(get_markeralpha(series, i)) gr_draw_marker(x[i], y[i], msi, shape) end end diff --git a/src/utils.jl b/src/utils.jl index 6153f4b4..08c85797 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -656,6 +656,31 @@ function get_fillalpha(series, i::Int = 1) _cycle(series[:fillalpha], i) end +function get_markercolor(series, i::Int = 1) + mc = series[:markercolor] + mz = series[:marker_z] + if mz == nothing + isa(mc, ColorGradient) ? mc : _cycle(mc, i) + else + cmin, cmax = get_clims(series[:subplot]) + grad = isa(mc, ColorGradient) ? mc : cgrad() + grad[clamp((_cycle(mz, i) - cmin) / (cmax - cmin), 0, 1)] + end +end + +function get_markeralpha(series, i::Int = 1) + _cycle(series[:markeralpha], i) +end + +function get_markerstrokecolor(series, i::Int = 1) + msc = series[:markerstrokecolor] + isa(msc, ColorGradient) ? msc : _cycle(msc, i) +end + +function get_markerstrokealpha(series, i::Int = 1) + _cycle(series[:markerstrokealpha], i) +end + function has_attribute_segments(series::Series) # we want to check if a series needs to be split into segments just because # of its attributes