From 0858de0449e49dba58c716b53b487d951fb6b8e4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 24 Apr 2020 00:01:36 +0200 Subject: [PATCH] add magic arguments --- src/args.jl | 4 ++-- test/test_pgfplotsx.jl | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/args.jl b/src/args.jl index 1f3f71d8..8dd8f950 100644 --- a/src/args.jl +++ b/src/args.jl @@ -482,7 +482,7 @@ const _subplot_args = sort(union(collect(keys(_subplot_defaults)))) const _plot_args = sort(union(collect(keys(_plot_defaults)))) const _magic_axis_args = [:axis, :tickfont, :guidefont, :grid, :minorgrid] -const _magic_subplot_args = [:titlefont, :legendfont, :legendtitlefont, ] +const _magic_subplot_args = [:titlefont, :legendfont, :legendtitlefont, :plot_titlefont, :colorbar_titlefont] const _magic_series_args = [:line, :marker, :fill] const _all_axis_args = sort(union([_axis_args; _magic_axis_args])) @@ -1062,7 +1062,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) end # fonts - for fontname in (:titlefont, :legendfont, :legendtitlefont) + for fontname in (:titlefont, :legendfont, :legendtitlefont, :plot_titlefont, :colorbar_titlefont) args = RecipesPipeline.pop_kw!(plotattributes, fontname, ()) for arg in wraptuple(args) processFontArg!(plotattributes, fontname, arg) diff --git a/test/test_pgfplotsx.jl b/test/test_pgfplotsx.jl index a61892f6..6d285a3d 100644 --- a/test/test_pgfplotsx.jl +++ b/test/test_pgfplotsx.jl @@ -359,11 +359,22 @@ end # testset end # testset @testset "Titlefonts" begin - pl = plot(1:5, title = ("Test me", 2, :left)) + pl = plot(1:5, title = "Test me", titlefont = (2, :left)) + @test pl[1][:title] == "Test me" + @test pl[1][:titlefontsize] == 2 + @test pl[1][:titlefonthalign] == :left Plots._update_plot_object(pl) ax_opt = Plots.pgfx_axes(pl.o)[1].options @test ax_opt["title"] == "Test me" if @test(haskey(ax_opt.dict, "title_style")) isa Test.Pass @test ax_opt["title style"]["at"] == "{(0,1)}" end + pl = plot(1:5, plot_title = "Test me", plot_titlefont = (2, :left)) + @test pl[:plot_title] == "Test me" + @test pl[:plot_titlefontsize] == 2 + @test pl[:plot_titlefonthalign] == :left + pl = heatmap(rand(3,3), colorbar_title = "Test me", colorbar_titlefont = (12, :right)) + @test pl[1][:colorbar_title] == "Test me" + @test pl[1][:colorbar_titlefontsize] == 12 + @test pl[1][:colorbar_titlefonthalign] == :right end # testset