You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, .Path extents are calculated by _path.h as simply the Bbox of the control points.
For bezier curves, the convex hull of the control points can be easily shown to contain the path. So these extents are a correct upper bound. However, especially for cubic curves, this upper bound will often not be even approximately equal. (See example below).
Presumably this hasn't been a problem in the past because in practice, matplotlib primarily deals with lines, where the control points are exactly the extents.
It might make sense to leave the current Path.get_extents code, and implement a Path.get_exact_extents to be used upon MarkerStyle.__init__ to pre-calculate/cache the Bbox of that marker.
This solution prevents incurring a (presumably significant) performance penalty for something that clearly has not been a big issue in the past, allows us to still quickly compute the Bbox of a collection of markers by adding the appropriate padding to the Bbox of the marker centers, and doesn't change existing API.
Someone who's more familiar with the Agg internals is free to translate my Python code if we decide it's worth it to implement a "fast" version of the "correct" solution for use on all Path's.
I will submit a PR to implement Path.get_exact_extents Python-side (not much work), but I wanted to open this up for discussion.
Bug report
Bug summary
Currently,
.Pathextents are calculated by_path.has simply theBboxof the control points.For bezier curves, the convex hull of the control points can be easily shown to contain the path. So these extents are a correct upper bound. However, especially for cubic curves, this upper bound will often not be even approximately equal. (See example below).
Some thoughts:
MarkerStyle.normalizationas initially proposed in Sizes of different markers are not perceptually uniform #15703 and discussed in Remove more API deprecated in 3.1 #16772.Path.get_extentscode, and implement aPath.get_exact_extentsto be used uponMarkerStyle.__init__to pre-calculate/cache theBboxof that marker.This solution prevents incurring a (presumably significant) performance penalty for something that clearly has not been a big issue in the past, allows us to still quickly compute the Bbox of a collection of markers by adding the appropriate padding to the Bbox of the marker centers, and doesn't change existing API.
Someone who's more familiar with the
Agginternals is free to translate my Python code if we decide it's worth it to implement a "fast" version of the "correct" solution for use on allPath's.I will submit a PR to implement
Path.get_exact_extentsPython-side (not much work), but I wanted to open this up for discussion.Code for reproduction
Actual outcome
Expected outcome
See title of plot.
Matplotlib version
print(matplotlib.get_backend())): qt5agg