Fix #2377, #2785, #2369: Legend positioning fix for multiple plots (#2784)

* Fix 2377: Legend positioning fix for multiple vertical plots

* Fix #2785: Legend positioning for multiple horizontal plots
This commit is contained in:
Maaz Bin Tahir Saeed 2020-06-17 14:16:37 +05:00 committed by GitHub
parent 99c8bfe12d
commit a9b9b3c357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -590,7 +590,7 @@ function gr_legend_pos(sp::Subplot, w, h, viewport_plotarea)
xpos = viewport_plotarea[1] + 0.11 xpos = viewport_plotarea[1] + 0.11
end end
else else
xpos = (viewport_plotarea[2]-viewport_plotarea[1])/2 - w/2 +.04 xpos = (viewport_plotarea[2]-viewport_plotarea[1])/2 - w/2 +.04 + viewport_plotarea[1]
end end
if occursin("top", str) if occursin("top", str)
if s == :outertop if s == :outertop
@ -605,7 +605,8 @@ function gr_legend_pos(sp::Subplot, w, h, viewport_plotarea)
ypos = viewport_plotarea[3] + h + 0.06 ypos = viewport_plotarea[3] + h + 0.06
end end
else else
ypos = (viewport_plotarea[4]-viewport_plotarea[3])/2 + h/2 # Adding min y to shift legend pos to correct graph (#2377)
ypos = (viewport_plotarea[4]-viewport_plotarea[3])/2 + h/2 + viewport_plotarea[3]
end end
(xpos,ypos) (xpos,ypos)
end end