Skip to content

Should zero-sized Rectangles be taken into account for autoscaling purposes? #19081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anntzer opened this issue Dec 7, 2020 · 4 comments
Open
Labels
API: consistency keep Items to be ignored by the “Stale” Github Action Maintenance status: needs comment/discussion needs consensus on next step

Comments

@anntzer
Copy link
Contributor

anntzer commented Dec 7, 2020

Currently, Rectangles with zero-width and zero-height are ignored for autoscaling purposes, but not other zero-sized patches:

from matplotlib import patches, pyplot as plt

ax = 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 in Axes._update_patch_limits) was introduced in f24d06c 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.

@WeatherGod
Copy link
Member

WeatherGod commented Dec 7, 2020 via email

@anntzer
Copy link
Contributor Author

anntzer commented Dec 8, 2020

I'm not sure what you are referring to, but in any case hist([4, 5, 6], range(10)) (for example, which does have empty bins on the sides) is not affected by the suggested removal (the empty bins are clearly included for autoscaling, with or without the snippet).

@timhoffm
Copy link
Member

IMHO zero-sized Rectangles should be taken into account.

If users don't want them, they will be able to exclude them via #15595 (once that is in). But excluding should be explicit.

@timhoffm timhoffm added the status: needs comment/discussion needs consensus on next step label Dec 28, 2020
@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Sep 18, 2023
@anntzer anntzer added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: consistency keep Items to be ignored by the “Stale” Github Action Maintenance status: needs comment/discussion needs consensus on next step
Projects
None yet
Development

No branches or pull requests

3 participants