FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Should zero-sized Rectangles be taken into account for autoscaling purposes? · Issue #19081 · matplotlib/matplotlib · GitHub

Repository navigation

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

Open

Description

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.

Activity

  1. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    on Dec 7, 2020
  2. WeatherGod commented on Dec 7, 2020

    Member
  3. anntzer commented on Dec 8, 2020

    ContributorAuthor

    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).

  4. timhoffm commented on Dec 28, 2020

    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.

  5. github-actions commented on Sep 18, 2023

    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!

  6. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …MaintenancekeepItems to be ignored by the “Stale” Github Actionstatus: needs comment/discussionneeds consensus on next step

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL