我设法创建了一个代码,在它周围输出一个球体和一个环,但是这个环看起来不像是圆形的球体......
有人可以救我吗?
代码:
import numpy as np
from matplotlib import pyplot as plt
import mpl_toolkits.mplot3d.axes3d
theta = np.linspace(0, 2.*np.pi, 100)
phi = np.linspace(0, 2*np.pi, 100)
theta, phi = np.meshgrid(theta, phi)
c, a = 10, 0.2
x = (c + a*np.cos(theta)) * np.cos(phi)
y = (c + a*np.cos(theta)) * np.sin(phi)
z = a * np.sin(theta)
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
ax1.set_zlim(-10,10)
ax1.plot_surface(x, y, z, rstride=5, cstride=5, color='b', edgecolors='b')
ax1.view_init(36, 26)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x2 = 4 * np.outer(np.cos(u), np.sin(v))
y2 = 4 * np.outer(np.sin(u), np.sin(v))
z2 = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax1.plot_surface(x2, y2, z2, rstride=5, cstride=5, color='r')
plt.show()