Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@anntzer

Description

@anntzer
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.