Skip to content Skip to sidebar Skip to footer

How To Plot An Ellipse By Its Equation On Python?

So I have this equation: x^2 + 4*(z+10)^2 = e^(-0.05*z) How cant I plot it using, for example, Matplotlib.pyplot and Numpy packages?

Solution 1:

My solution is: Calculate each side of equation for a given x and z gridded. Then I contour points that satisfy the equation. One side minus other equals to zero.

import numpy as np
import matplotlib.pyplotas plt

z = -np.linspace(9,15,100)
x = np.linspace(-26,26,1000)

x,z = np.meshgrid(x,z)

Z = -np.exp(-0.05*z) +4*(z+10)**2 
X = x**2


plt.contour(x,z,(X+Z),[0])
plt.xlim([-1.5,1.5])
plt.ylim([-11.5,-8.5])

Out

Solution 2:

Use the plot_implicit function of sympy http://docs.sympy.org/latest/modules/plotting.html or use Sage http://www.sagemath.org/.

Post a Comment for "How To Plot An Ellipse By Its Equation On Python?"