improve legend position

This commit is contained in:
Simon Christ 2020-05-20 13:07:41 +02:00
parent b03eb234b6
commit d4134adf4a

View File

@ -179,12 +179,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) : sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) :
nothing nothing
# legend position # legend position
if sp[:legend] isa Tuple push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
x, y = sp[:legend]
push!(axis_opt["legend style"], "at={($x, $y)}")
else
push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
end
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
if letter != :z || RecipesPipeline.is3d(sp) if letter != :z || RecipesPipeline.is3d(sp)
pgfx_axis!(axis_opt, sp, letter) pgfx_axis!(axis_opt, sp, letter)
@ -690,6 +685,8 @@ pgfx_get_legend_pos(k) = get(
Symbol(k), Symbol(k),
("at" => string((1.02, 1)), "anchor" => "north west"), ("at" => string((1.02, 1)), "anchor" => "north west"),
) )
pgfx_get_legend_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "north west")
pgfx_get_legend_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor))
pgfx_get_colorbar_pos(s) = pgfx_get_colorbar_pos(s) =
get((left = " left", bottom = " horizontal", top = " horizontal"), s, "") get((left = " left", bottom = " horizontal", top = " horizontal"), s, "")