Use an instance of me to evaluate the overlap score of a proposed position of an annotation, based on subplot data, boundaries, and the positions of all other annotations in the subplot.

All subplot data is converted to, and computations done in, pixel units.

Method __init__ Undocumented
Method avoid Call to have annotations avoid the region defined by any supplied Matplotlib obj having a get_window_extent method.
Method with_boundary Returns score for the proposed RectangleRegion rr possibly overlapping with (or going beyond) axis or figure boundary.
Method with_others Returns score for the proposed RectangleRegion rr possibly overlapping with any annotation other than the specified one ann.
Method with_data Returns score for the proposed RectangleRegion rr possibly overlapping with my subplot's X,Y data.
Method with_avoided Returns score for the proposed RectangleRegion rr possibly overlapping with Matplotlib objects that have been registered to avoid with calls to avoid.
Method score Computes the total overlap score for the annotation if it were positioned in my subplot at the specified offset dx and dy in pixels from its data point.
def __init__(self, ax, pairs, annotations):
Undocumented
def avoid(self, obj):

Call to have annotations avoid the region defined by any supplied Matplotlib obj having a get_window_extent method.

def with_boundary(self, rr):

Returns score for the proposed RectangleRegion rr possibly overlapping with (or going beyond) axis or figure boundary.

The score is twice as high for an overlap with the figure boundary.

def with_others(self, rr, ann):

Returns score for the proposed RectangleRegion rr possibly overlapping with any annotation other than the specified one ann.

The score increases with the number of overlaps.

def with_data(self, rr):

Returns score for the proposed RectangleRegion rr possibly overlapping with my subplot's X,Y data.

The score increases with the number of plot lines overlapped.

This is by far the slowest analysis to run when there is a typically large number of X,Y data points. However, it is made considerably more efficient by skipping overlap checking for a given set of X,Y data until the right end of the segment is to the right of the left side of rr, and by quitting further checking after the right end of the segment goes beyond the right side of rr.

TODO: Make even more efficient by using Numpy's testing and selection capabilities to select the relevant slice of X,Y data for possible segment overlap.

def with_avoided(self, rr):

Returns score for the proposed RectangleRegion rr possibly overlapping with Matplotlib objects that have been registered to avoid with calls to avoid.

The score increases with the number of overlaps.

def score(self, ann, dx, dy):

Computes the total overlap score for the annotation if it were positioned in my subplot at the specified offset dx and dy in pixels from its data point.

A higher overlap score is worse. A zero overlap score (best case) indicates no overlap with anything else at that offset. My awful score is considered as bad as it gets: There's no point in differentiating between it and anything worse.

Returns a 2-tuple with the overlap score and the RectangleRegion object I construct for its proposed location in my subplot, or None if no realistic size can be determined for the region.

Sometimes my Sizer simply cannot provide a realistic estimate of the annotation's size. When the estimated size is too small to be realistic, no RectangleRegion is constructed and None is returned instead of the 2-tuple. Weirdly, a realistic size will often be computed at a different position, so the workaround is to just proceed with the next candidate position and re-do the score for this one once a realistic size has been determined.

API Documentation for yampex, generated by pydoctor at 2022-11-21 15:03:54.