Fix legend placement bug