【发布时间】:2019-06-07 17:10:15
【问题描述】:
我正在尝试使用 matplotlib 仅绘制半个圆环。
这是我目前的方法:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
n = 100
# theta: poloidal angle; phi: toroidal angle
theta = np.linspace(0, 2.*np.pi, n)
phi = np.linspace(0, 2.*np.pi, n)
theta, phi = np.meshgrid(theta, phi)
# R0: major radius; a: minor radius
R0, a = 2., 1.
# torus parametrization
x = (R0 + a*np.cos(theta)) * np.cos(phi)
y = (R0 + a*np.cos(theta)) * np.sin(phi)
z = a * np.sin(theta)
# "cut-off" half of the torus
x[x>0] = np.nan
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
ax1.set_zlim(-3,3)
ax1.plot_surface(x, y, z, rstride=5, cstride=5,)
# elev: elevation angle in z-plane
# azim: azimuth angle in x,y plane
ax1.view_init(elev=15, azim=0)
plt.show()
这样做,确实给了我半个圆环,但是其中一个切割面不清楚,如图所示(这里有问题的是左侧切割面)。
任何想法如何制作干净的切割表面?
【问题讨论】:
标签: python numpy matplotlib 3d