-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Comments
Wasn't there something a long while back for including this for regular
(not log-based) hist/bar graphs that had an empty bar on the edges that was
getting clipped out by auto-limits? Or is that handled separately?
…On Mon, Dec 7, 2020 at 5:50 PM Antony Lee ***@***.***> wrote:
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
<f24d06c>
to support log-scaled histograms with empty bins, but is not necessary
anymore as hist autoscaling was fully reworked in #14581
<#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 <#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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#19081>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6HSSN7LBWFQJXEJA3DSTVLZVANCNFSM4UREBBGQ>
.
|
I'm not sure what you are referring to, but in any case |
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. |
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! |
Currently, Rectangles with zero-width and zero-height are ignored for autoscaling purposes, but not other zero-sized patches:
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.
The text was updated successfully, but these errors were encountered: