Open
Description
Bug summary
I was following thissexample on drawing ellipses and wanted to get the vertices out. Calling Ellipse.get_vertices() returns the untransformed vertices which may be intended behaviour, but I also seem to be unable to produce the correct vertices under the transform and they seem to be off by a scale factor. Not entirely sure if it's a bug or something I don't understand.
The following code is a MWE trimmed down from the linked example
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
import matplotlib.transforms as transforms
fig, ax = plt.subplots(figsize=(6, 6))
ellipse = Ellipse((0, 0), width=1.15*2, height=2*0.823)
transf = transforms.Affine2D() \
.rotate_deg(45) \
.scale(2.54, 1.94) \
.translate(3.64, 4.0)
ellipse.set_transform(transf + ax.transData)
ax.add_patch(ellipse)
vertices = ellipse.get_vertices()
transformed_vertices = ellipse.get_transform().transform(vertices)
data_verts = ax.transData.inverted().transform(transformed_vertices)
ax.plot([vertices[0][0],vertices[1][0]],[vertices[0][1],vertices[1][1]],c='green')
ax.plot([data_verts[0][0],data_verts[1][0]],[data_verts[0][1],data_verts[1][1]],c='red')
plt.savefig('ellipse_test.png')
plt.show()
Actual outcome
Expected outcome
The red line to have endpoints associated with the vertices of the ellipse
Additional information
No response
Operating system
Ubuntu
Matplotlib Version
3.10.3
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Metadata
Metadata
Assignees
Labels
No labels