pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/45a6a6f2f0268207393d22b4431a5b78130f288c

rigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Add getters to EllipseColletion · matplotlib/matplotlib@45a6a6f · GitHub
Skip to content

Commit 45a6a6f

Browse files
committed
Add getters to EllipseColletion
1 parent e4c5938 commit 45a6a6f

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

lib/matplotlib/collections.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,20 +1805,32 @@ def _set_angles(self, angles):
18051805
self._angles = np.deg2rad(angles).ravel()
18061806

18071807
def set_widths(self, widths):
1808-
"""Set the lengths of the first axes (e.g., major axis lengths)."""
1808+
"""Set the lengths of the first axes (e.g., major axis)."""
18091809
self._set_widths(widths)
18101810
self.stale = True
18111811

18121812
def set_heights(self, heights):
1813-
"""Set the lengths of second axes.."""
1813+
"""Set the lengths of second axes (e.g., minor axes)."""
18141814
self._set_heights(heights)
18151815
self.stale = True
18161816

1817+
def get_widths(self):
1818+
"""Get the lengths of the first axes (e.g., major axis)."""
1819+
return self._widths * 2
1820+
1821+
def get_heights(self):
1822+
"""Set the lengths of second axes (e.g., minor axes)."""
1823+
return self._heights * 2
1824+
18171825
def set_angles(self, angles):
18181826
"""Set the angles of the first axes, degrees CCW from the x-axis."""
18191827
self._set_angles(angles)
18201828
self.stale = True
18211829

1830+
def get_angles(self):
1831+
"""Get the angles of the first axes, degrees CCW from the x-axis."""
1832+
return np.rad2deg(self._angles)
1833+
18221834
@artist.allow_rasterization
18231835
def draw(self, renderer):
18241836
self._set_transforms()

lib/matplotlib/collections.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ class EllipseCollection(Collection):
181181
**kwargs
182182
) -> None: ...
183183
def set_widths(self, widths: ArrayLike) -> None: ...
184+
def get_widths(self) -> ArrayLike: ...
184185
def set_heights(self, heights: ArrayLike) -> None: ...
186+
def get_heights(self) -> ArrayLike: ...
185187
def set_angles(self, angles: ArrayLike) -> None: ...
188+
def get_angles(self) -> ArrayLike: ...
186189

187190
class PatchCollection(Collection):
188191
def __init__(

lib/matplotlib/tests/test_collections.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def test_EllipseCollection():
408408
ax.autoscale_view()
409409

410410

411-
def test_EllipseCollection_setter():
411+
def test_EllipseCollection_setter_getter():
412412
# Test widths, heights and angle setter
413413
rng = np.random.default_rng(0)
414414

@@ -432,6 +432,10 @@ def test_EllipseCollection_setter():
432432
assert_array_almost_equal(ec._heights, np.array(heights).ravel() * 0.5)
433433
assert_array_almost_equal(ec._angles, np.deg2rad(angles).ravel())
434434

435+
assert_array_almost_equal(ec.get_widths(), widths)
436+
assert_array_almost_equal(ec.get_heights(), heights)
437+
assert_array_almost_equal(ec.get_angles(), angles)
438+
435439
ax.add_collection(ec)
436440
ax.set_xlim(-2, 12)
437441
ax.set_ylim(-2, 12)
@@ -442,9 +446,9 @@ def test_EllipseCollection_setter():
442446

443447
ec.set(widths=new_widths, heights=new_heights, angles=new_angles)
444448

445-
assert_array_almost_equal(ec._widths, np.array(new_widths).ravel() * 0.5)
446-
assert_array_almost_equal(ec._heights, np.array(new_heights).ravel() * 0.5)
447-
assert_array_almost_equal(ec._angles, np.deg2rad(new_angles).ravel())
449+
assert_array_almost_equal(ec.get_widths(), new_widths.ravel())
450+
assert_array_almost_equal(ec.get_heights(), new_heights.ravel())
451+
assert_array_almost_equal(ec.get_angles(), new_angles.ravel())
448452

449453

450454
@image_comparison(['polycollection_close.png'], remove_text=True, style='mpl20')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy