How to make eclipses using matplotlib


import matplotlib.pyplot as py
x_list=[];x_list2=[]

y_list=[];y_list2=[]
def eclipse(a,b,r):
	i=0
	while i<(a*r)**0.5:
		i+=0.01
		
		x_list.append(i);x_list2.append(-i)
		y_list.append((b*(r-(i**2)/a))**0.5);y_list2.append(0-(b*(r-(i**2)/a))**0.5)
	
	py.xlim(-r,r)
	py.ylim(-r,r)
	py.plot(x_list,y_list)
	py.plot(x_list,y_list2)
	py.plot(x_list2,y_list2)
	py.plot(x_list2,y_list)
	
	py.show()

[@tacaswell edited to add markup]

If you want to plot ellipse, I suggest looking at matplotlib.patches.Ellipse — Matplotlib 3.6.0 documentation which tries to render with a little error as possible.

Thank you for the suggestion sir, I’ll try it if I get to work with eeclipses in near future
Though this code I only made for practicing mathematics and trying to apply it , that’s why I tried to avoid codes already written by any programmer already