Matplotlib产生意外形状

时间:2018-12-07 06:17:54

标签: python matplotlib plot geometry-surface

我正在尝试绘制几何函数的曲面:

import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.cm as cmx
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import pylab
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
theta, phi = np.linspace(1e-5, 2 * np.pi-0.001, 400), np.linspace(1e-5, 3*np.pi/5.5, 400)
PHI, THETA = np.meshgrid(theta, phi)
theta1 = np.sqrt(7.5*(-1+np.sqrt(1-0.8*0.1*1./8.*(-8. + THETA*(5 + 3.*np.cos(2*PHI))/np.tan(THETA) + (5. + np.cos(THETA))* (np.sin(PHI))**2))))
R = (np.sin(theta1)+0.00000001)/(np.sin(theta1 + THETA)+0.00000001)
X = R * np.cos(THETA)
Y = R * np.sin(THETA) * np.cos(PHI)
Z = R * np.sin(THETA) * np.sin(PHI)
surf = ax.plot_surface(X, Y, Z)
plt.show()

在鼻子上,我得到了一个完全不期望的扭结。我应该获得一个光滑的抛物面型的鼻子。有什么方法可以解决这个问题吗?

注意:如果我在SphericalPlot3D中尝试Mathematica,则不会出现任何此类问题。 plot the above code produces

0 个答案:

没有答案