I have the following code, which generates a circle polygon (A polygon-approximation of a circle patch.) using Python matplotlib.
import matplotlib.pyplot as plt
from matplotlib.patches import CirclePolygon
circle = CirclePolygon((0, 0), radius = 0.75, fc = 'y')
plt.gca().add_patch(circle)
plt.axis('scaled')
plt.show()
For the code above, I have the output given below:
I need all the points that are together forming the circle polygon. How can this be achieved?
The Polygon is based on a path. You may get this path via circle.get_path()
. You're interested in the vertices
of this path.
Finally you need to transform them according to the Polygon's transform.
import matplotlib.pyplot as plt
from matplotlib.patches import CirclePolygon
circle = CirclePolygon((0, 0), radius = 0.75, fc = 'y')
plt.gca().add_patch(circle)
verts = circle.get_path().vertices
trans = circle.get_patch_transform()
points = trans.transform(verts)
print(points)
plt.plot(points[:,0],points[:,1])
plt.axis('scaled')
plt.show()
The blue line is a plot of the thus obtained points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With