Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not plot legend upon single series #4964

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PlotsBase/src/Commons/attrs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ const _bar_width = 0.8
# -----------------------------------------------------------------------------

const _series_defaults = KW(
:label => :auto,
:label => :none,
:colorbar_entry => true,
:seriescolor => :auto,
:seriesalpha => nothing,
Expand Down
10 changes: 5 additions & 5 deletions PlotsBase/test/test_args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ end
end

@testset "Series Attributes" begin
pl = plot([[1, 2, 3], [2, 3, 4]], lw = 5)
@test hline!(deepcopy(pl), [1.75])[1].series_list[3][:label] ==
hline!(deepcopy(pl), [1.75], z_order = :front)[1].series_list[3][:label] ==
pl = plot([[1, 2, 3], [2, 3, 4]], lw = 5, label=:auto)
@test hline!(deepcopy(pl), [1.75], label=:auto)[1].series_list[3][:label] ==
hline!(deepcopy(pl), [1.75], z_order = :front, label=:auto)[1].series_list[3][:label] ==
"y3"
@test hline!(deepcopy(pl), [1.75], z_order = :back)[1].series_list[1][:label] == "y3"
@test hline!(deepcopy(pl), [1.75], z_order = 2)[1].series_list[2][:label] == "y3"
@test hline!(deepcopy(pl), [1.75], z_order = :back, label=:auto)[1].series_list[1][:label] == "y3"
@test hline!(deepcopy(pl), [1.75], z_order = 2, label=:auto)[1].series_list[2][:label] == "y3"
sp = pl[1]
@test isempty(sp[1][:extra_kwargs])
@test sp[2][:series_index] == 2
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ with(:gr) do
@test plot([0:1 reverse(0:1)]; labels = ["a" "b"], leg = (0.5, :inner)) isa
PlotsBase.Plot
@test_logs (:warn, r"n° of legend_column.*") png(
plot(1:2, legend_columns = 10),
plot(1:2, legend_columns = 10, label=:auto),
tempname(),
)
end
Expand Down
6 changes: 3 additions & 3 deletions PlotsBase/test/test_pgfplotsx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ with(:pgfplotsx) do

@testset "Legends" begin
pl = plot(rand(5, 2), lab = ["1" ""], arrow = true)
scatter!(pl, rand(5))
scatter!(pl, rand(5), label=:auto)
axis_contents = first(get_pgf_axes(pl)).contents
leg_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis_contents)
series = filter(x -> x isa PGFPlotsX.Plot, axis_contents)
Expand Down Expand Up @@ -93,8 +93,8 @@ with(:pgfplotsx) do
end

@testset "Plot in pieces" begin
pl = plot(rand(100) / 3, reg = true, fill = (0, :green))
scatter!(pl, rand(100), markersize = 6, c = :orange)
pl = plot(rand(100) / 3, reg = true, fill = (0, :green), label=:auto)
scatter!(pl, rand(100), markersize = 6, c = :orange, label=:auto)
axis_contents = first(get_pgf_axes(pl)).contents
leg_entries = filter(x -> x isa PGFPlotsX.LegendEntry, axis_contents)
series = filter(x -> x isa PGFPlotsX.Plot, axis_contents)
Expand Down
Loading