Merge pull request #1475 from daschw/pgf-legendmarker

Filled legend marker for filled areas in PGFPlots
This commit is contained in:
Daniel Schwabeneder 2018-04-06 20:20:09 +02:00 committed by GitHub
commit 1d38e50281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,10 +269,15 @@ function pgf_series(sp::Subplot, series::Series)
# add to legend? # add to legend?
if i == 1 && sp[:legend] != :none && should_add_to_legend(series) if i == 1 && sp[:legend] != :none && should_add_to_legend(series)
if d[:fillrange] != nothing
push!(style, "forget plot")
push!(series_collection, pgf_fill_legend_hack(d, args))
else
kw[:legendentry] = d[:label] kw[:legendentry] = d[:label]
if st == :shape # || d[:fillrange] != nothing if st == :shape # || d[:fillrange] != nothing
push!(style, "area legend") push!(style, "area legend")
end end
end
else else
push!(style, "forget plot") push!(style, "forget plot")
end end
@ -336,6 +341,25 @@ function pgf_fillrange_args(fillrange, x, y, z)
return x_fill, y_fill, z_fill return x_fill, y_fill, z_fill
end 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
# ---------------------------------------------------------------- # ----------------------------------------------------------------