diff --git a/src/backends/gr.jl b/src/backends/gr.jl index a3d86d9c..60fdba5b 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -949,9 +949,11 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # draw the line(s) if st == :path - gr_set_line(series[:linewidth], series[:linestyle], get_linecolor(sp, series)) #, series[:linealpha]) - arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none - gr_polyline(x, y; arrowside = arrowside) + for (i,rng) in enumerate(iter_segments(series[:x], series[:y])) + gr_set_line(series[:linewidth], series[:linestyle], get_linecolor(sp, series, i)) #, series[:linealpha]) + arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none + gr_polyline(series[:x][rng], series[:y][rng]; arrowside = arrowside) + end gr_set_line(1, :solid, yaxis[:foreground_color_axis]) cmap && gr_colorbar(sp, clims) end @@ -1173,7 +1175,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) for series in series_list(sp) should_add_to_legend(series) || continue st = series[:seriestype] - gr_set_line(series[:linewidth], series[:linestyle], get_linecolor(sp, series)) #, series[:linealpha]) + gr_set_line(series[:linewidth], series[:linestyle], get_linecolor(sp, series, 1)) #, series[:linealpha]) if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing gr_set_fill(series[:fillcolor]) #, series[:fillalpha]) diff --git a/src/utils.jl b/src/utils.jl index 38bb2b5a..f9a6cb0c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -587,14 +587,15 @@ function hascolorbar(sp::Subplot) hascbar end -function get_linecolor(sp::Subplot, series::Series) +function get_linecolor(sp::Subplot, series::Series, i::Int) lc = series[:linecolor] - if series[:line_z] == nothing - lc + lz = series[:line_z] + if lz == nothing + _cycle(lc, i) else cmin, cmax = get_clims(sp) grad = isa(lc, ColorGradient) ? lc : cgrad() - grad[clamp((series[:line_z] - cmin) / (cmax -cmin), 0, 1)] + grad[clamp((_cycle(lz, i) - cmin) / (cmax -cmin), 0, 1)] end end