From e498d091cd553c92d4e20287ac91d4250d762f89 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 6 Apr 2018 17:14:19 +0200 Subject: [PATCH 1/2] filled legend marker for filled area in PGFPlots --- src/backends/pgfplots.jl | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 1dd2b272..6c8929a5 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -269,9 +269,14 @@ function pgf_series(sp::Subplot, series::Series) # add to legend? if i == 1 && sp[:legend] != :none && should_add_to_legend(series) - kw[:legendentry] = d[:label] - if st == :shape # || d[:fillrange] != nothing - push!(style, "area legend") + if d[:fillrange] != nothing + # we add a series + push!(series_collection, pgf_fill_legend_hack(d, args)) + else + kw[:legendentry] = d[:label] + if st == :shape # || d[:fillrange] != nothing + push!(style, "area legend") + end end else push!(style, "forget plot") @@ -336,6 +341,25 @@ function pgf_fillrange_args(fillrange, x, y, z) return x_fill, y_fill, z_fill end +function pgf_fill_legend_hack(d, args) + style = [] + kw = KW() + push!(style, pgf_linestyle(d, 1)) + push!(style, pgf_marker(d, 1)) + push!(style, pgf_fillstyle(d, 1)) + push!(style, "area legend") + kw[:legendentry] = d[:label] + kw[:style] = join(style, ',') + st = d[:seriestype] + func = if st == :path3d + PGFPlots.Linear3 + elseif st == :scatter + PGFPlots.Scatter + else + PGFPlots.Linear + end + return func(([arg[1]] for arg in args)...; kw...) +end # ---------------------------------------------------------------- From 5a07c4917ef781ad576a037fa631848b7acc219a Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 6 Apr 2018 18:37:57 +0200 Subject: [PATCH 2/2] fix multiple series --- src/backends/pgfplots.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 6c8929a5..51eb2565 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -270,7 +270,7 @@ function pgf_series(sp::Subplot, series::Series) # add to legend? if i == 1 && sp[:legend] != :none && should_add_to_legend(series) if d[:fillrange] != nothing - # we add a series + push!(style, "forget plot") push!(series_collection, pgf_fill_legend_hack(d, args)) else kw[:legendentry] = d[:label]