MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / unit_regular_polygon

Method unit_regular_polygon

lib/matplotlib/path.py:790–809  ·  view source on GitHub ↗

Return a :class:`Path` instance for a unit regular polygon with the given *numVertices* such that the circumscribing circle has radius 1.0, centered at (0, 0).

(cls, numVertices)

Source from the content-addressed store, hash-verified

788
789 @classmethod
790 def unit_regular_polygon(cls, numVertices):
791 """
792 Return a :class:`Path` instance for a unit regular polygon with the
793 given *numVertices* such that the circumscribing circle has radius 1.0,
794 centered at (0, 0).
795 """
796 if numVertices <= 16:
797 path = cls._unit_regular_polygons.get(numVertices)
798 else:
799 path = None
800 if path is None:
801 theta = ((2 * np.pi / numVertices) * np.arange(numVertices + 1)
802 # This initial rotation is to make sure the polygon always
803 # "points-up".
804 + np.pi / 2)
805 verts = np.column_stack((np.cos(theta), np.sin(theta)))
806 path = cls(verts, closed=True, readonly=True)
807 if numVertices <= 16:
808 cls._unit_regular_polygons[numVertices] = path
809 return path
810
811 _unit_regular_stars = WeakValueDictionary()
812

Callers 9

_set_tuple_markerMethod · 0.80
_set_pentagonMethod · 0.80
_set_hexagon1Method · 0.80
_set_hexagon2Method · 0.80
_set_octagonMethod · 0.80
__init__Method · 0.80
test_uses_per_pathFunction · 0.80
test_path_collectionFunction · 0.80
_gen_axes_spinesMethod · 0.80

Calls 1

getMethod · 0.45

Tested by 2

test_uses_per_pathFunction · 0.64
test_path_collectionFunction · 0.64