-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Correct theta values when drawing a non-circular arc #8047
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Elliptical arcs now drawn between correct angles | ||
```````````````````````````````````````````````` | ||
|
||
The `matplotlib.patches.Arc` patch is now correctly drawn between the given | ||
angles. | ||
|
||
Previously a circular are was drawn and then stretched into an ellipse, | ||
so the resulting arc did not lie between *theta1* and *theta2*. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -982,6 +982,32 @@ def test_canonical(): | |
ax.plot([1, 2, 3]) | ||
|
||
|
||
@image_comparison(baseline_images=['arc_angles'], remove_text=True, | ||
style='default', extensions=['png']) | ||
def test_arc_angles(): | ||
from matplotlib import patches | ||
# Ellipse parameters | ||
w = 2 | ||
h = 1 | ||
centre = (0.2, 0.5) | ||
|
||
fig, axs = plt.subplots(3, 3) | ||
for i, ax in enumerate(axs.flat): | ||
theta2 = i * 360 / 9 | ||
theta1 = theta2 - 45 | ||
ax.add_patch(patches.Ellipse(centre, w, h, alpha=0.3)) | ||
ax.add_patch(patches.Arc(centre, w, h, theta1=theta1, theta2=theta2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a full |
||
# Straight lines intersecting start and end of arc | ||
ax.plot([2 * np.cos(np.deg2rad(theta1)) + centre[0], | ||
centre[0], | ||
2 * np.cos(np.deg2rad(theta2)) + centre[0]], | ||
[2 * np.sin(np.deg2rad(theta1)) + centre[1], | ||
centre[1], | ||
2 * np.sin(np.deg2rad(theta2)) + centre[1]]) | ||
ax.set_xlim(-2, 2) | ||
ax.set_ylim(-2, 2) | ||
|
||
|
||
@image_comparison(baseline_images=['arc_ellipse'], | ||
remove_text=True) | ||
def test_arc_ellipse(): | ||
|
@@ -990,23 +1016,23 @@ def test_arc_ellipse(): | |
width, height = 1e-1, 3e-1 | ||
angle = -30 | ||
|
||
theta = np.arange(0.0, 360.0, 1.0)*np.pi/180.0 | ||
x = width/2. * np.cos(theta) | ||
y = height/2. * np.sin(theta) | ||
theta = np.arange(0.0, 360.0, 1.0) * np.pi / 180.0 | ||
x = width / 2. * np.cos(theta) | ||
y = height / 2. * np.sin(theta) | ||
|
||
rtheta = angle*np.pi/180. | ||
rtheta = angle * np.pi / 180. | ||
R = np.array([ | ||
[np.cos(rtheta), -np.sin(rtheta)], | ||
[np.sin(rtheta), np.cos(rtheta)], | ||
]) | ||
[np.cos(rtheta), -np.sin(rtheta)], | ||
[np.sin(rtheta), np.cos(rtheta)]]) | ||
|
||
x, y = np.dot(R, np.array([x, y])) | ||
x += xcenter | ||
y += ycenter | ||
|
||
fig = plt.figure() | ||
ax = fig.add_subplot(211, aspect='auto') | ||
ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1) | ||
ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', | ||
linewidth=1, zorder=1) | ||
|
||
e1 = patches.Arc((xcenter, ycenter), width, height, | ||
angle=angle, linewidth=2, fill=False, zorder=2) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are -> arc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops...