fix for case when marker is at the edge of the plot