From 8b4edae35858a12533332719ce568aab4693f7f9 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 24 Sep 2017 20:52:02 +0200 Subject: [PATCH] implement line_z for GR --- src/backends/gr.jl | 10 +++++++--- src/utils.jl | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index ebd35f20..a3d86d9c 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -22,7 +22,7 @@ const _gr_attr = merge_with_base_supported([ :tickfont, :guidefont, :legendfont, :grid, :gridalpha, :gridstyle, :gridlinewidth, :legend, :legendtitle, :colorbar, - :marker_z, :levels, + :line_z, :marker_z, :levels, :ribbon, :quiver, :orientation, :overwrite_figure, @@ -896,6 +896,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) gr_set_gradient(series[:fillcolor]) #, series[:fillalpha]) elseif series[:marker_z] != nothing series[:markercolor] = gr_set_gradient(series[:markercolor]) + elseif series[:line_z] != nothing + series[:linecolor] = gr_set_gradient(series[:linecolor]) end GR.savestate() @@ -947,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], series[:linecolor]) #, series[:linealpha]) + 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) + gr_set_line(1, :solid, yaxis[:foreground_color_axis]) + cmap && gr_colorbar(sp, clims) end end @@ -1169,7 +1173,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], series[:linecolor]) #, series[:linealpha]) + gr_set_line(series[:linewidth], series[:linestyle], get_linecolor(sp, series)) #, 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 bc13d191..38bb2b5a 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -587,6 +587,17 @@ function hascolorbar(sp::Subplot) hascbar end +function get_linecolor(sp::Subplot, series::Series) + lc = series[:linecolor] + if series[:line_z] == nothing + lc + else + cmin, cmax = get_clims(sp) + grad = isa(lc, ColorGradient) ? lc : cgrad() + grad[clamp((series[:line_z] - cmin) / (cmax -cmin), 0, 1)] + end +end + # --------------------------------------------------------------- makekw(; kw...) = KW(kw)