added plot position calculation