1

If I am plotting a surface with the following script, i get some problems with self-occlusion of the surface as shown below. Is there a way to fix it?

Probably has to do something with 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

Community
  • 1
  • 1
Zappel
  • 268
  • 3
  • 13
  • I'm afraid these are well known issues in matplotlib. Recently I gave an answer for a question that had similar problems. You should take a look into it: https://stackoverflow.com/questions/37380912/matplotlib-3d-plot-plot-surface-black/37501084#37501084 – armatita May 29 '16 at 20:34

0 Answers0