Skip to content

Commit

Permalink
do not plot legend upon single series
Browse files Browse the repository at this point in the history
  • Loading branch information
isentropic committed Jul 18, 2024
1 parent 617b8aa commit 31b9a96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PlotsBase/src/Commons/attrs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1150,13 +1150,15 @@ _replace_linewidth(plotattributes::AKW) =
DEFAULT_LINEWIDTH[]
end

label_auto(series_plotindex) = string("y", series_plotindex)
label_to_string(label::Bool, series_plotindex) =
label ? label_to_string(:auto, series_plotindex) : ""
label_to_string(label::Nothing, series_plotindex) = ""
label_to_string(label::Missing, series_plotindex) = ""
label_to_string(label::Symbol, series_plotindex) =
if label :auto
string("y", series_plotindex)
return label_auto(series_plotindex)
elseif label :none
""
else
Expand Down
5 changes: 5 additions & 0 deletions PlotsBase/src/DataSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using ..PlotsBase: DefaultsDict, RecipesPipeline, get_attr_symbol, KW
using ..PlotUtils: ColorGradient, plot_color
using ..RecipesBase: @recipe
using ..Commons
using ..Commons: label_auto

mutable struct Series
plotattributes::DefaultsDict
Expand All @@ -51,6 +52,10 @@ Base.append!(series::Series, args...) = extend_series!(series, args...)
should_add_to_legend(series::Series) =
series.plotattributes[:primary] &&
series.plotattributes[:label] != "" &&
!(
length(series_list(series[:subplot])) == 1 &&
series.plotattributes[:label] == label_auto(series.plotattributes[:series_plotindex])
) &&
series.plotattributes[:seriestype] (
:hexbin,
:bins2d,
Expand Down

0 comments on commit 31b9a96

Please sign in to comment.