Plot Ellipse with matplotlib.pyplot

The matplotlib ellipse demo is nice. But I could not implement it in my code without a for loop. I was getting an axes figure error. Here is what I did instead, where of course the xy center are my own coordinates with respective width and height based on the image over which I plotted the ellipse.

from matplotlib.patches import Ellipse

plt.figure()
ax = plt.gca()

ellipse = Ellipse(xy=(157.18, 68.4705), width=0.036, height=0.012, 
                        edgecolor="r", fc="None", lw=2)
ax.add_patch(ellipse)

This code is based partially on the very first code box on this page. See Chris’s response above for a link to matplotlib.patches.Ellipse.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)