Skip to content

Commit f074713

Browse files
author
Johann Krauter
committed
added entries in stubs, resolve docu issues
1 parent bbf76e7 commit f074713

File tree

3 files changed

+15
-63
lines changed

3 files changed

+15
-63
lines changed

galleries/examples/shapes_and_collections/ellipse_arrow.py

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,26 @@
1616

1717

1818
# Create a figure and axis
19-
fig, ax = plt.subplots(1, 1, subplot_kw={"aspect": "equal"})
19+
fig, ax = plt.subplots(subplot_kw={"aspect": "equal"})
2020

2121
# Define an ellipse clockwise
22-
center = (2, 4)
23-
width = 30
24-
height = 20
25-
angle = 35
26-
ellipse_clockwise = Ellipse(
22+
center=(2, 4)
23+
width=30
24+
height=20
25+
angle=35
26+
ellipse = Ellipse(
2727
xy=center,
2828
width=width,
2929
height=height,
3030
angle=angle,
3131
facecolor="none",
32-
edgecolor="b",
33-
label="clockwise"
32+
edgecolor="b"
3433
)
35-
36-
# Get position of vertex for arrow marker
37-
vertices = ellipse_clockwise.get_co_vertices()
38-
39-
# Add the ellipse patch to the axis
40-
ax.add_patch(ellipse_clockwise)
34+
ax.add_patch(ellipse)
4135

4236
# Plot a arrow marker at the end point of minor axis
43-
t = Affine2D().rotate_deg(ellipse_clockwise.angle)
37+
vertices = ellipse.get_co_vertices()
38+
t = Affine2D().rotate_deg(ellipse.angle)
4439
ax.plot(
4540
vertices[0][0],
4641
vertices[0][1],
@@ -49,54 +44,8 @@
4944
markersize=10
5045
)
5146

52-
# Define an second ellipse counterclockwise
53-
center = (2, 4)
54-
width = 30
55-
height = 15
56-
angle = -20
57-
ellipse_counterclockwise = Ellipse(
58-
xy=center,
59-
width=width,
60-
height=height,
61-
angle=angle,
62-
facecolor="none",
63-
edgecolor="g",
64-
label="counterclockwise"
65-
)
66-
67-
# Add the ellipse patch to the axis
68-
ax.add_patch(ellipse_counterclockwise)
69-
70-
# Get position of vertex for arrow marker
71-
vertices = ellipse_counterclockwise.get_co_vertices()
72-
73-
# Plot a arrow marker at the end point of minor axis
74-
t = Affine2D().rotate_deg(ellipse_counterclockwise.angle)
75-
ax.plot(
76-
vertices[0][0],
77-
vertices[0][1],
78-
color="g",
79-
marker=MarkerStyle("<", "full", t),
80-
markersize=10
81-
)
82-
83-
84-
plt.legend()
8547
plt.show()
8648

87-
center = (2, 4)
88-
width = 30
89-
height = 20
90-
angle = 35
91-
ellipse = Ellipse(
92-
xy=center,
93-
width=width,
94-
height=height,
95-
angle=angle
96-
)
97-
print(ellipse.get_vertices())
98-
print(ellipse.get_co_vertices())
99-
10049
# %%
10150
#
10251
# .. admonition:: References

lib/matplotlib/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ def get_vertices(self):
16581658
"""
16591659
Return the left and right vertex coordinates of the ellipse.
16601660
1661-
The definition can be found `here<https://en.wikipedia.org/wiki/Ellipse>`_
1661+
The definition can be found `here <https://en.wikipedia.org/wiki/Ellipse>`_
16621662
"""
16631663
x0 = self._center[0] - self._width / 2 * np.cos(np.deg2rad(self._angle))
16641664
y0 = self._center[1] - self._width / 2 * np.sin(np.deg2rad(self._angle))
@@ -1670,7 +1670,7 @@ def get_co_vertices(self):
16701670
"""
16711671
Return the left and right co-vertex coordinates of the ellipse.
16721672
1673-
The definition can be found `here<https://en.wikipedia.org/wiki/Ellipse>`_
1673+
The definition can be found `here <https://en.wikipedia.org/wiki/Ellipse>`_
16741674
"""
16751675
x0 = self._center[0] - self._height / 2 * np.sin(np.deg2rad(self._angle))
16761676
y0 = self._center[1] + self._height / 2 * np.cos(np.deg2rad(self._angle))

lib/matplotlib/patches.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ class Ellipse(Patch):
258258
angle = property(get_angle, set_angle)
259259

260260
def get_corners(self) -> np.ndarray: ...
261+
262+
def get_vertices(self) -> list[float, float]: ...
263+
def get_co_vertices(self) -> list[float, float]: ...
261264

262265
class Annulus(Patch):
263266
a: float

0 commit comments

Comments
 (0)