I manage the annotations for all axes in a single subplot. You'll need an instance of me for each subplot that contains annotations.

Construct me with the Matplotlib Axes object for my subplot and a PlotHelper.Pairs instance that holds PlotHelper.Pair objects representing the info for one X, Y pair of vectors to be plotted. Call add on the instance to add each new annotation, and update to intelligently (re)position the annotations to avoid overlap with subplot borders, plot data, and other annotations.

See AlsoPlotHelper.addAnnotations and PlotHelper.updateAnnotations.
Instance Variable sizer An instance of Sizer for estimating dimensions of Matplotlib annotation objects.
Instance Variable pos An instance of PositionEvaluator that uses my sizer instance.
Instance Variable annotations A list of all Matplotlib annotation objects in my subplot. A reference is passed to the constructor of Sizer and used by it as well.
Instance Variable boxprops A dict containing names and values for the properties of the bounding boxes for the annotations I create. Based on defaults in _boxprops.
Method __init__ Undocumented
Method setVerbose Undocumented
Method avoid Call to have annotations avoid the region defined by any supplied Matplotlib obj having a get_window_extent method.
Method add Adds an annotation with an arrow pointing at data-value coordinates x and y and displaying the supplied text inside a round-bordered text box.
Method update Call this to have all added annotations intelligently repositioned.
Class Variable _boxprops Default values for annotation object bounding box properties.
Method _paddingForSize Returns the amount of padding (in what units???) for the bounding boxes of all annotations I produce, given my fontsize.
Method _offseterator Iterates over possible annotation offset positions, rotating clockwise around a central point.
Method _move Moves the supplied annotation by setting its text position to dx and dy.
sizer =
An instance of Sizer for estimating dimensions of Matplotlib annotation objects.
pos =
An instance of PositionEvaluator that uses my sizer instance.
annotations =
A list of all Matplotlib annotation objects in my subplot. A reference is passed to the constructor of Sizer and used by it as well.
boxprops =
A dict containing names and values for the properties of the bounding boxes for the annotations I create. Based on defaults in _boxprops.
_boxprops =
Default values for annotation object bounding box properties.
def __init__(self, ax, pairs, **kw):
Undocumented
def setVerbose(self, yes=True):
Undocumented
def _paddingForSize(self):

Returns the amount of padding (in what units???) for the bounding boxes of all annotations I produce, given my fontsize.

def _offseterator(self):

Iterates over possible annotation offset positions, rotating clockwise around a central point.

After one full rotation, another rotation is done at a larger offset radius. Once the radius get big enough, the box positions include not just 45-degree points on the compass, but also points in between.

Each iteration yields a 2-tuple with (1) the horizontal offset dx in pixels to the right of the data point, and (2) the vertical offset dx in pixels above the data point.

def avoid(self, obj):

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

def add(self, x, y, text, dx=0, dy=0):

Adds an annotation with an arrow pointing at data-value coordinates x and y and displaying the supplied text inside a round-bordered text box.

The annotation will be added to my Matplotlib Axes object ax right on top of its data-value coordinates. Obviously, it can't stay there, so you need to call update to move it to an appropriate place once the rest of the subplot has been added. You also should call update if the annotation needs to be repositioned due to a change in the figure dimensions.

The keywords dx and dy are specified (in pixels) when this method gets called again by _move to intelligently reposition an annotation by replacing it with a new one.

Returns a reference to the new Matplotlib annotation object.

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

Moves the supplied annotation by setting its text position to dx and dy.

def update(self, *args, **kw):

Call this to have all added annotations intelligently repositioned.

All arguments and keywords are accepted but disregarded, making this is a convenient GUI hook or Twisted callback.

Returns True if anything was repositioned, False if everything stayed the same. You can use that info to decide whether to redraw.

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