pyiem.plot.textcollider module#

Rectangle-based label collision tracking used by plot_values.

class pyiem.plot.textcollider.TextCollider[source]#

Bases: object

Track claimed label boxes (display pixels) and test new ones.

Each claimed box carries a priority (zorder). A candidate collides only with claimed boxes of equal or higher priority, so higher priority labels drawn later are never culled by lower priority ones drawn earlier.

__len__()[source]#

Number of claimed boxes.

collides(bbox, zorder, xpad=0.0, ypad=0.0)[source]#

Does bbox (x0, y0, x1, y1) overlap a claimed box?

Both boxes are inflated by the padding, so the minimum clear gap between two accepted labels is 2 * pad.

Return type:

bool

claim(bbox, zorder)[source]#

Record a box as occupied.

try_claim(bbox, zorder, xpad=0.0, ypad=0.0)[source]#

Claim the box unless it collides, returning if it was claimed.

Return type:

bool