Fix #2848: Legend :top should start below axis spine (#2870)

* Account for adding dy to ymax in legend pos

* Subtract x legend offset from :right symbols
This commit is contained in:
Maaz Bin Tahir Saeed 2020-07-23 12:48:14 +05:00 committed by GitHub
parent 1ee999af33
commit 7e122bdfea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -585,7 +585,7 @@ function gr_legend_pos(sp::Subplot, w, h, viewport_plotarea)
# As per https://github.com/jheinen/GR.jl/blob/master/src/jlgr.jl#L525 # As per https://github.com/jheinen/GR.jl/blob/master/src/jlgr.jl#L525
xpos = viewport_plotarea[2] + x_legend_offset + legend_leftw + ymirror * gr_axis_width(sp, sp[:yaxis]) xpos = viewport_plotarea[2] + x_legend_offset + legend_leftw + ymirror * gr_axis_width(sp, sp[:yaxis])
else else
xpos = viewport_plotarea[2] - legend_rightw - legend_textw xpos = viewport_plotarea[2] - legend_rightw - legend_textw - x_legend_offset
end end
elseif occursin("left", str) elseif occursin("left", str)
if occursin("outer", str) if occursin("outer", str)
@ -600,7 +600,7 @@ function gr_legend_pos(sp::Subplot, w, h, viewport_plotarea)
if s == :outertop if s == :outertop
ypos = viewport_plotarea[4] + y_legend_offset + legendh + xmirror * gr_axis_height(sp, sp[:xaxis]) ypos = viewport_plotarea[4] + y_legend_offset + legendh + xmirror * gr_axis_height(sp, sp[:xaxis])
else else
ypos = viewport_plotarea[4] - y_legend_offset ypos = viewport_plotarea[4] - y_legend_offset - legend_dy
end end
elseif occursin("bottom", str) elseif occursin("bottom", str)
if s == :outerbottom if s == :outerbottom