fix bug of resetting position on legend change