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

Fix plotattributes in _add_plot_title! #4090

Merged
merged 5 commits into from
Feb 7, 2022
Merged
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 src/args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ end

function _add_plot_title!(plt)
plot_title = plt[:plot_title]
plot_titleindex = nothing

if plot_title != ""
# make new subplot for plot title
Expand Down Expand Up @@ -319,7 +320,7 @@ function _add_plot_title!(plt)
end
end

return nothing
return plot_titleindex
end

## Series recipes
Expand Down
4 changes: 2 additions & 2 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ function plot!(plt1::Plot, plt2::Plot, plts_tail::Plot...; kw...)
cmdidx += 1
end
end
_add_plot_title!(plt)
ttl_idx = _add_plot_title!(plt)

# first apply any args for the subplots
for (idx, sp) in enumerate(plt.subplots)
_update_subplot_args(plt, sp, plotattributes, idx, false)
_update_subplot_args(plt, sp, idx == ttl_idx ? KW() : plotattributes, idx, false)
end

# finish up
Expand Down
32 changes: 19 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ end
Plots.use_local_dependencies[] = temp
end

include("test_defaults.jl")
include("test_pipeline.jl")
include("test_axes.jl")
include("test_layouts.jl")
include("test_contours.jl")
include("test_axis_letter.jl")
include("test_components.jl")
include("test_shorthands.jl")
include("integration_dates.jl")
include("test_recipes.jl")
include("test_hdf5plots.jl")
include("test_pgfplotsx.jl")
include("test_plotly.jl")
for fn in (
"test_defaults.jl",
"test_pipeline.jl",
"test_axes.jl",
"test_layouts.jl",
"test_contours.jl",
"test_axis_letter.jl",
"test_components.jl",
"test_shorthands.jl",
"integration_dates.jl",
"test_recipes.jl",
"test_hdf5plots.jl",
"test_pgfplotsx.jl",
"test_plotly.jl",
)
@testset "$fn" begin
include(fn)
end
end

reference_dir(args...) =
joinpath(homedir(), ".julia", "dev", "PlotReferenceImages", args...)
Expand Down
7 changes: 7 additions & 0 deletions test/test_layouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ 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[1][:framestyle] === :grid
@test p[2][:framestyle] === :grid
@test p[3][:framestyle] === :none
end