From 155634ef34cdc761251033f9dfe959c0ebd8a153 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 2 Jul 2017 18:32:34 +0200 Subject: [PATCH 1/5] change gr legend marker for ribbon --- src/backends/gr.jl | 2 +- src/utils.jl | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 989a0751..a79cf62f 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1049,7 +1049,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) should_add_to_legend(series) || continue st = series[:seriestype] gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha]) - if st == :path && series[:fillrange] == nothing + if st == :path && (series[:fillrange] == nothing || has_ribbon(series)) GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) elseif st == :shape || series[:fillrange] != nothing gr_set_fill(series[:fillcolor]) #, series[:fillalpha]) diff --git a/src/utils.jl b/src/utils.jl index 2b0720fe..84d82ea5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -493,10 +493,16 @@ function make_fillrange_from_ribbon(kw::KW) y, rib = kw[:y], kw[:ribbon] rib = wraptuple(rib) rib1, rib2 = -first(rib), last(rib) - kw[:ribbon] = nothing + # kw[:ribbon] = nothing kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) end +# check if series has a ribbon +function has_ribbon(series::Series) + series[:ribbon] == nothing && return false + return series[:ribbon] > 0 +end + function get_sp_lims(sp::Subplot, letter::Symbol) axis_limits(sp[Symbol(letter, :axis)]) end From 52f042263b21acc27774d94da841bb7fbc5b51a6 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 20 Jul 2017 23:38:16 +0200 Subject: [PATCH 2/5] fix case --- src/backends/gr.jl | 2 +- src/utils.jl | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index a79cf62f..6168a1de 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1049,7 +1049,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) should_add_to_legend(series) || continue st = series[:seriestype] gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha]) - if st == :path && (series[:fillrange] == nothing || has_ribbon(series)) + if st == :path && (series[:fillrange] == nothing || series[:ribbon] != nothing) GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) elseif st == :shape || series[:fillrange] != nothing gr_set_fill(series[:fillcolor]) #, series[:fillalpha]) diff --git a/src/utils.jl b/src/utils.jl index 84d82ea5..d8aced3d 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -497,12 +497,6 @@ function make_fillrange_from_ribbon(kw::KW) kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) end -# check if series has a ribbon -function has_ribbon(series::Series) - series[:ribbon] == nothing && return false - return series[:ribbon] > 0 -end - function get_sp_lims(sp::Subplot, letter::Symbol) axis_limits(sp[Symbol(letter, :axis)]) end From 9f712b44f34fce4efa927f7d1439e3b93fc114db Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 21 Jul 2017 09:12:27 +0200 Subject: [PATCH 3/5] add ribbon area to marker --- src/backends/gr.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 6168a1de..acb06b04 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1049,16 +1049,19 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) should_add_to_legend(series) || continue st = series[:seriestype] gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha]) - if st == :path && (series[:fillrange] == nothing || series[:ribbon] != nothing) - GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) - elseif st == :shape || series[:fillrange] != nothing + + if st == :shape || series[:fillrange] != nothing gr_set_fill(series[:fillcolor]) #, series[:fillalpha]) l, r = xpos-0.07, xpos-0.01 b, t = ypos-0.4dy, ypos+0.4dy x = [l, r, r, l, l] y = [b, b, t, t, b] gr_polyline(x, y, GR.fillarea) - gr_polyline(x, y) + series[:ribbon] != nothing || gr_polyline(x, y) + end + + if st == :path && (series[:fillrange] == nothing || series[:ribbon] != nothing) + GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) end if series[:markershape] != :none From 96d34bb5eeaf82a9ec20c08d6930e64374b0cdda Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 21 Jul 2017 10:05:27 +0200 Subject: [PATCH 4/5] changed marker for path with fillrange --- src/backends/gr.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index acb06b04..a3a40caf 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1057,11 +1057,15 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) x = [l, r, r, l, l] y = [b, b, t, t, b] gr_polyline(x, y, GR.fillarea) - series[:ribbon] != nothing || gr_polyline(x, y) + st == :shape && gr_polyline(x, y) end - if st == :path && (series[:fillrange] == nothing || series[:ribbon] != nothing) - GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) + if st == :path + if series[:fillrange] == nothing || series[:ribbon] != nothing + GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) + else + GR.polyline([xpos - 0.07, xpos - 0.01], [ypos+0.4dy, ypos+0.4dy]) + end end if series[:markershape] != :none From 0fa459d590a38c4529bd1d17346ed9b36a3f97e1 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 21 Jul 2017 10:52:36 +0200 Subject: [PATCH 5/5] fix alpha in legend markers --- src/backends/gr.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index a3a40caf..4c36bf00 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -272,6 +272,10 @@ function normalize_zvals(zv::AVec) end end + +gr_alpha(α::Void) = 1 +gr_alpha(α::Real) = α + # --------------------------------------------------------- # draw ONE Shape @@ -1042,6 +1046,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if sp[:legendtitle] != nothing GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF) gr_set_textcolor(sp[:foreground_color_legend]) + GR.settransparency(1) gr_text(xpos - 0.03 + 0.5*w, ypos, string(sp[:legendtitle])) ypos -= dy end @@ -1056,11 +1061,14 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) b, t = ypos-0.4dy, ypos+0.4dy x = [l, r, r, l, l] y = [b, b, t, t, b] + GR.settransparency(gr_alpha(series[:fillalpha])) gr_polyline(x, y, GR.fillarea) + GR.settransparency(gr_alpha(series[:linealpha])) st == :shape && gr_polyline(x, y) end if st == :path + GR.settransparency(gr_alpha(series[:linealpha])) if series[:fillrange] == nothing || series[:ribbon] != nothing GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) else