From f355ff9904611fc672cebe4c2b3575328d87d0e5 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 6 May 2021 21:27:24 +0200 Subject: [PATCH] clean up pgfx-legends duplications --- src/backends/pgfplotsx.jl | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index b6cb96c1..6583006b 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -142,7 +142,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) axis_opt = PGFPlotsX.Options( "point meta max" => get_clims(sp)[2], "point meta min" => get_clims(sp)[1], - "legend cell align" => "left", "title" => sp[:title], "title style" => PGFPlotsX.Options( pgfx_get_title_pos(title_loc)..., @@ -154,22 +153,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) "draw opacity" => title_a, "rotate" => sp[:titlefontrotation], ), - "legend style" => PGFPlotsX.Options( - pgfx_linestyle( - pgfx_thickness_scaling(sp), - sp[:foreground_color_legend], - fg_alpha, - "solid", - ) => nothing, - "fill" => cstr, - "fill opacity" => a, - "text opacity" => alpha(plot_color(sp[:legendfontcolor])), - "font" => pgfx_font( - sp[:legendfontsize], - pgfx_thickness_scaling(sp), - ), - "text" => plot_color(sp[:legendfontcolor]), - ), + "legend style" => pgfx_get_legend_style(sp), "axis background/.style" => PGFPlotsX.Options( "fill" => bgc_inside, "opacity" => bgc_inside_a, @@ -183,11 +167,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) nothing sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) : nothing - # legend position / formatting - push!(axis_opt["legend style"], - pgfx_get_legend_pos(sp[:legend])... - ) - merge!(axis_opt["legend style"], pgfx_get_legend_style(sp)) for letter in (:x, :y, :z) if letter != :z || RecipesPipeline.is3d(sp) pgfx_axis!(axis_opt, sp, letter) @@ -805,8 +784,22 @@ end function pgfx_get_legend_style(sp) legfont = legendfont(sp) PGFPlotsX.Options( + pgfx_linestyle( + pgfx_thickness_scaling(sp), + sp[:foreground_color_legend], + fg_alpha, + "solid", + ) => nothing, + "fill" => cstr, + "fill opacity" => a, + "text opacity" => alpha(plot_color(sp[:legendfontcolor])), + "font" => pgfx_font( + sp[:legendfontsize], + pgfx_thickness_scaling(sp), + ), + "text" => plot_color(sp[:legendfontcolor]), "cells" => PGFPlotsX.Options("anchor" => get((left = "west", right = "east", hcenter = "center"), legfont.halign, "west")), - "font" => pgfx_font(legfont.pointsize, pgfx_thickness_scaling(sp)) + pgfx_get_legend_pos(sp[:legend])..., ) end