fix plotattributes in _add_plot_title!
This commit is contained in:
parent
2a7d2d710e
commit
c09e05c407
@ -2059,7 +2059,7 @@ function _update_subplot_args(
|
||||
)
|
||||
anns = RecipesPipeline.pop_kw!(sp.attr, :annotations)
|
||||
|
||||
# # grab those args which apply to this subplot
|
||||
# grab those args which apply to this subplot
|
||||
for k in keys(_subplot_defaults)
|
||||
slice_arg!(plotattributes_in, sp.attr, k, subplot_index, remove_pair)
|
||||
end
|
||||
|
||||
@ -266,7 +266,7 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
|
||||
sp_attrs[sp] = attr
|
||||
end
|
||||
|
||||
_add_plot_title!(plt)
|
||||
_add_plot_title!(plt, plotattributes)
|
||||
# override subplot/axis args. `sp_attrs` take precendence
|
||||
for (idx, sp) in enumerate(plt.subplots)
|
||||
attr = if !haskey(plotattributes, :subplot) || plotattributes[:subplot] == idx
|
||||
@ -287,7 +287,7 @@ function series_idx(kw_list::AVec{KW}, kw::AKW)
|
||||
Int(kw[:series_plotindex]) - Int(kw_list[1][:series_plotindex]) + 1
|
||||
end
|
||||
|
||||
function _add_plot_title!(plt)
|
||||
function _add_plot_title!(plt, plotattributes)
|
||||
plot_title = plt[:plot_title]
|
||||
|
||||
if plot_title != ""
|
||||
@ -308,6 +308,9 @@ function _add_plot_title!(plt)
|
||||
plt[:plot_titleindex] = subplot[:subplot_index]
|
||||
subplot[:framestyle] = :none
|
||||
subplot[:margin] = 0px
|
||||
# prevents propagation (see JuliaPlots/Plots.jl/issues/4083)
|
||||
pop!(plotattributes, :framestyle, nothing)
|
||||
pop!(plotattributes, :margin, nothing)
|
||||
push!(plt.subplots, subplot)
|
||||
end
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ function plot!(plt1::Plot, plt2::Plot, plts_tail::Plot...; kw...)
|
||||
cmdidx += 1
|
||||
end
|
||||
end
|
||||
_add_plot_title!(plt)
|
||||
_add_plot_title!(plt, plotattributes)
|
||||
|
||||
# first apply any args for the subplots
|
||||
for (idx, sp) in enumerate(plt.subplots)
|
||||
|
||||
@ -25,3 +25,8 @@ end
|
||||
@test pl[:plot_title] == "My new title"
|
||||
@test pl[:plot_titleindex] == 5
|
||||
end
|
||||
|
||||
@testset "Plots.jl/issues/4083" begin
|
||||
p = plot(plot(1:2), plot(1:2); border = :grid, plot_title = "abc")
|
||||
@test p.subplots[end][:framestyle] === :none
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user