The code you show does not represent the equation of the ellipse. It’s a bit hard to tell what exactly you were trying in that code, but the approach here is of course completely the same as in the linked question’s answer, namely to calculate the left hand side of the equation with a meshgrid and show the level of the right hand side as a contour
line.
import numpy as np
import matplotlib.pyplot as plt
x = -np.linspace(-0.5,+0.5,1000)
y = np.linspace(-0.5,+0.5,1000)
X,Y = np.meshgrid(x,y)
#equation: 7.91x^2 + -0.213xy + 5.46y^2 -0.031x -0.0896y = 1
eqn = 7.91* X**2 -0.213*X*Y + 5.46*Y**2 -0.031*X - 0.0896*Y
Z = 1
plt.contour(X,Y,eqn,[Z])
plt.xlim([-0.6,0.6])
plt.ylim([-0.6,+0.6])
plt.show()
1
solved Plot an ellipse with python 2.7 knowing the equation