From 59043b2244115f2ecbdbd3ee6385a8015ecef54f Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 20 May 2020 11:46:12 +0200 Subject: [PATCH] improve titlelocation --- src/backends/pgfplotsx.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 67a4d85c..111768da 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -141,15 +141,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) "legend cell align" => "left", "title" => sp[:title], "title style" => PGFPlotsX.Options( - "at" => if title_loc == :left - "{(0,1)}" - elseif title_loc == :right - "{(1,1)}" - elseif title_loc isa Tuple - "{$(string(title_loc))}" - else - "{(0.5,1)}" - end, + pgfx_get_title_pos(title_loc)..., "font" => pgfx_font( sp[:titlefontsize], pgfx_thickness_scaling(sp), @@ -703,6 +695,14 @@ pgfx_get_colorbar_pos(s) = get((left = " left", bottom = " horizontal", top = " horizontal"), s, "") pgfx_get_colorbar_pos(b::Bool) = "" +pgfx_get_title_pos(s) = + get(( + left = ("at" => "{(0,1)}", "anchor" => "south west"), + right = ("at" => "{(1,1)}", "anchor" => "south east"), + ), s, "{(0.5,1)}") +pgfx_get_title_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "south") +pgfx_get_title_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor)) + function pgfx_get_ticklabel_style(sp, axis) cstr = plot_color(axis[:tickfontcolor]) return PGFPlotsX.Options(