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

Remove ineffective exclusion of Arcs without parent Axes. by anntzer · Pull Request #23336 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
32 changes: 13 additions & 19 deletions lib/matplotlib/patches.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1907,14 +1907,9 @@ class Arc(Ellipse):
"""
An elliptical arc, i.e. a segment of an ellipse.

Due to internal optimizations, there are certain restrictions on using Arc:

- The arc cannot be filled.

- The arc must be used in an `~.axes.Axes` instance. It can not be added
directly to a `.Figure` because it is optimized to only render the
segments that are inside the axes bounding box with high resolution.
Due to internal optimizations, the arc cannot be filled.
"""

def __str__(self):
pars = (self.center[0], self.center[1], self.width,
self.height, self.angle, self.theta1, self.theta2)
Expand Down Expand Up @@ -1997,12 +1992,11 @@ def draw(self, renderer):
with each visible arc using a fixed number of spline segments
(8). The algorithm proceeds as follows:

1. The points where the ellipse intersects the axes bounding
box are located. (This is done be performing an inverse
transformation on the axes bbox such that it is relative
to the unit circle -- this makes the intersection
calculation much easier than doing rotated ellipse
intersection directly).
1. The points where the ellipse intersects the axes (or figure)
bounding box are located. (This is done by performing an inverse
transformation on the bbox such that it is relative to the unit
circle -- this makes the intersection calculation much easier than
doing rotated ellipse intersection directly.)

This uses the "line intersecting a circle" algorithm from:

Expand All @@ -2016,8 +2010,6 @@ def draw(self, renderer):
pairs of vertices are drawn using the Bezier arc
approximation technique implemented in `.Path.arc`.
"""
if not hasattr(self, 'axes'):
raise RuntimeError('Arcs can only be used in Axes instances')
if not self.get_visible():
return

Expand Down Expand Up @@ -2104,10 +2096,12 @@ def segment_circle_intersect(x0, y0, x1, y1):
& (y0e - epsilon < ys) & (ys < y1e + epsilon)
]

# Transforms the axes box_path so that it is relative to the unit
# circle in the same way that it is relative to the desired ellipse.
box_path_transform = (transforms.BboxTransformTo(self.axes.bbox)
+ self.get_transform().inverted())
# Transform the axes (or figure) box_path so that it is relative to
# the unit circle in the same way that it is relative to the desired
# ellipse.
box_path_transform = (
transforms.BboxTransformTo((self.axes or self.figure).bbox)
- self.get_transform())
box_path = Path.unit_rectangle().transformed(box_path_transform)

thetas = set()
Expand Down

Back | FazBrowse Home | New Git URL