Merge 91bfdabd857dc446a254a6891ef2282508fc081d into 13141feb4f3a7a950ba0e471b11617ecd1d8f6a2

This commit is contained in:
t-bltg 2021-08-04 13:40:16 +02:00 committed by GitHub
commit d4ac92aa51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -1658,12 +1658,13 @@ function _slice_series_args!(plotattributes::AKW, plt::Plot, sp::Subplot, comman
return plotattributes return plotattributes
end 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::Bool, series_plotindex) = label ? label_to_string(:auto, series_plotindex) : ""
label_to_string(label::Nothing, series_plotindex) = "" label_to_string(label::Nothing, series_plotindex) = ""
label_to_string(label::Missing, series_plotindex) = "" label_to_string(label::Missing, series_plotindex) = ""
function label_to_string(label::Symbol, series_plotindex) function label_to_string(label::Symbol, series_plotindex)
if label==:auto if label==:auto
return string("y", series_plotindex) return label_auto(series_plotindex)
elseif label==:none elseif label==:none
return "" return ""
else else

View File

@ -396,7 +396,7 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
end end
end end
if k == 1 && if k == 1 &&
series[:subplot][:legend] != :none && pgfx_should_add_to_legend(series) series[:subplot][:legend] != :none && pgfx_should_add_to_legend(series)
pgfx_filllegend!(series_opt, opt) pgfx_filllegend!(series_opt, opt)
end end
end end
@ -948,8 +948,12 @@ function pgfx_font(fontsize::Nothing, thickness_scaling = 1, font = "\\selectfon
return string("{", font, "}") return string("{", font, "}")
end end
function pgfx_should_add_to_legend(series::Series) pgfx_should_add_to_legend(series::Series) = (
series.plotattributes[:primary] && series.plotattributes[:primary] &&
!(
length(series_list(series[:subplot])) == 1 &&
series.plotattributes[:label] == label_auto(series.plotattributes[:series_plotindex])
) &&
!( !(
series.plotattributes[:seriestype] in ( series.plotattributes[:seriestype] in (
:hexbin, :hexbin,
@ -964,7 +968,7 @@ function pgfx_should_add_to_legend(series::Series)
:image, :image,
) )
) )
end )
function pgfx_marker(plotattributes, i = 1) function pgfx_marker(plotattributes, i = 1)
shape = _cycle(plotattributes[:markershape], i) shape = _cycle(plotattributes[:markershape], i)

View File

@ -41,9 +41,13 @@ get_subplot_index(plt::Plot, sp::Subplot) = findfirst(x -> x === sp, plt.subplot
series_list(sp::Subplot) = sp.series_list # filter(series -> series.plotattributes[:subplot] === sp, sp.plt.series_list) series_list(sp::Subplot) = sp.series_list # filter(series -> series.plotattributes[:subplot] === sp, sp.plt.series_list)
function should_add_to_legend(series::Series) should_add_to_legend(series::Series) = (
series.plotattributes[:primary] && series.plotattributes[:primary] &&
series.plotattributes[:label] != "" && series.plotattributes[:label] != "" &&
!(
length(series_list(series[:subplot])) == 1 &&
series.plotattributes[:label] == label_auto(series.plotattributes[:series_plotindex])
) &&
!( !(
series.plotattributes[:seriestype] in ( series.plotattributes[:seriestype] in (
:hexbin, :hexbin,
@ -60,6 +64,6 @@ function should_add_to_legend(series::Series)
:image, :image,
) )
) )
end )
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------