Matplotlib 3d表面遮挡不能正常工作

时间:2016-05-29 18:28:01

标签: python matplotlib

如果我使用以下脚本绘制曲面,我会遇到一些表面自遮挡的问题,如下所示。 有办法解决吗?

可能必须对this question执行某些操作。

import numpy
import matplotlib.pyplot
from mpl_toolkits.mplot3d import axes3d

def directivity(f, d, phi, n):
    speed_of_sound = 330
    summed = 1
    for n in numpy.arange(1, (n-1)/2 + 1, 1):
        summed += 2 * numpy.cos(2 * numpy.pi * f / speed_of_sound * n * d * numpy.cos(phi))
    return summed

def normalized_directivity(f, d, phi, n):
    direct = directivity(f, d, phi, n)
    return direct / numpy.max(direct)

frequencies = numpy.linspace(0, 5000, 1000)
angles = numpy.linspace(0, numpy.pi, 1000)

fig = matplotlib.pyplot.figure(figsize=(50,30))
ax = fig.add_subplot(111, projection='3d')
x, y = numpy.meshgrid(frequencies, angles)
surf = ax.plot_surface(x, y, numpy.abs(normalized_directivity(x, 0.1, y, 5)), rstride=10, cstride=10, cmap=matplotlib.cm.Spectral, antialiased=False)

ax.view_init(40, 315)
matplotlib.pyplot.savefig("test.svg")

self occlusion problem

0 个答案:

没有答案