allow numeric legend positioning in pyplot

This commit is contained in:
Daniel Schwabeneder 2019-04-30 15:25:08 +02:00
parent e860ba220a
commit 4742ec972b
2 changed files with 9 additions and 2 deletions

View File

@ -1251,6 +1251,12 @@ const _pyplot_legend_pos = KW(
:topleft => "upper left" :topleft => "upper left"
) )
py_legend_pos(pos::Symbol) = get(_pyplot_legend_pos, pos, "best")
py_legend_pos(pos) = "lower left"
py_legend_bbox(pos::Symbol) = (0, 0, 1, 1)
py_legend_bbox(pos) = pos
function py_add_legend(plt::Plot, sp::Subplot, ax) function py_add_legend(plt::Plot, sp::Subplot, ax)
leg = sp[:legend] leg = sp[:legend]
clims = get_clims(sp) clims = get_clims(sp)
@ -1288,7 +1294,8 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
if !isempty(handles) if !isempty(handles)
leg = ax."legend"(handles, leg = ax."legend"(handles,
labels, labels,
loc = get(_pyplot_legend_pos, leg, "best"), loc = py_legend_pos(leg),
bbox_to_anchor = py_legend_bbox(leg),
scatterpoints = 1, scatterpoints = 1,
fontsize = py_thickness_scale(plt, sp[:legendfontsize]), fontsize = py_thickness_scale(plt, sp[:legendfontsize]),
facecolor = py_color(sp[:background_color_legend]), facecolor = py_color(sp[:background_color_legend]),