Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Currently, Rectangles with zero-width and zero-height are ignored for autoscaling purposes, but not other zero-sized patches:
frommatplotlibimportpatches,pyplotaspltax=plt.figure().add_subplot()ax.add_patch(patches.Rectangle((-5,-5),0,0))# zero-sized at (-5, -5)ax.add_patch(patches.Circle((5,5),0))# zero-radius at (5, 5)ax.relim()ax.autoscale_view()plt.show()
results in axes autoscaled around (5, 5) (so they include the circle, but not the rectangle). I would argue that Rectangles should never be ignored, even if they have zero-width and zero-height, both for consistency with other patches, and because such Rectangles are likely not drawn with no reason.
This behavior (implemented inAxes._update_patch_limits
) was introduced inf24d06c to support log-scaled histograms with empty bins, but is not necessary anymore as hist autoscaling was fully reworked in#14581, making this behavior unnecessary (the check in_update_patch_limits
can be deleted with no bad effects); perhaps it was even already unnecessary before though.
Also, note that#2942 already weakened the original patch by going from ignoring Rectangles with zero width OR height to only ignoring Rectangles with zero width and height.