Fix too many legend entries (#3511)

* add test

* fix legend entries
This commit is contained in:
Simon Christ 2021-05-19 08:27:41 +02:00 committed by GitHub
parent a1311e5c60
commit de7717b85f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -452,7 +452,7 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
),
)
end
pgfx_add_legend!(axis, series, opt, i)
pgfx_add_legend!(axis, series, opt, k)
end # for segments
# get that last marker
if !isnothing(opt[:y]) && !any(isnan, opt[:y]) && opt[:markershape] isa AVec

View File

@ -338,6 +338,16 @@ end
plots = filter(x -> x isa PGFPlotsX.Plot, axis.contents)
@test length(plots) == 9
end # testset
@testset "Groups and Subplots" begin
group = rand(map((i->begin
"group $(i)"
end), 1:4), 100)
pl = plot(rand(100), layout = @layout([a b; c]), group = group, linetype = [:bar :scatter :steppre], linecolor = :match)
Plots._update_plot_object(pl)
axis = Plots.pgfx_axes(pl.o)[1]
legend_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis.contents)
@test length(legend_entries) == 2
end
end # testset
@testset "Extra kwargs" begin