Made the legend draw below or above the plot area in cases where it is placed in a corner and the layout is horizontal.
Test case for the previous
Fixed comment. Closes #3494.
Merge remote-tracking branch 'upstream/master'