I would like to plot the line: (x^2)/11.39 + (y^2)/6.25 = 1 rotated around the x-axis for a project I am working on.
I have used matplotlib to graph some 3D planes before but am unable to figure out how I would draw the revolution of a line around the x-axis.
I'm thinking I would have to use ax.plot_surface but am not quite sure how.
Thanks.
Here are my meager attempts using plot_surface
, meshgrid
, and trigonometry:
import numpy as np
import matplotlib.pyplot as plt
a2, b2 = 11.39, 6.26
X = np.linspace(-np.sqrt(a2), np.sqrt(a2), 100)
Theta = np.linspace(0, 2.1*np.pi, 1000)
X, Theta = np.meshgrid(X, Theta)
Y0 = np.sqrt(b2 * (1 - X**2 / a2))
Y = Y0 * np.cos(Theta)
Z = Y0 * np.sin(Theta)
fig,ax = plt.subplots(subplot_kw={'projection':'3d'})
ax.set_box_aspect((np.ptp(X), np.ptp(Y), np.ptp(Z)))
ax.plot_surface(X, Y, Z)
ax.set_xlabel('x')
plt.show()