Fixed legend overflow issue in #2076 with the fix proposed by @patheard.
Merge branch 'v3.0'