allow numeric legend positioning in pyplot
This commit is contained in:
parent
e860ba220a
commit
4742ec972b
@ -784,7 +784,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
tbx, tby = gr_inqtext(0, 0, string(lab))
|
tbx, tby = gr_inqtext(0, 0, string(lab))
|
||||||
legendw = max(legendw, tbx[3] - tbx[1])
|
legendw = max(legendw, tbx[3] - tbx[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
GR.setscale(1)
|
GR.setscale(1)
|
||||||
GR.selntran(1)
|
GR.selntran(1)
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|||||||
@ -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]),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user