Getting rid of artifacts / grid lines when building three-dimensional surfaces

When constructing surfaces using mpl_toolkits.mplot3d.Axes3D.plot_surface() , lines appear that apparently follow the curve of the surfaces on which the graphs are plotted. For instance:

 X, Y = numpy.meshgrid(numpy.arange(some_range), numpy.arange(some_other_range)) Z1, Z2 = numpy.array(getRate()) #getRate is a function that returns an array of shape (len(some_range), len(some_other_range) fig = pyplot.figure() ax = mplot3d.Axes3D(fig) ax.plot_surface(X, Y, Z1, color='w', alpha=0.2) ax.plot_surface(X, Y, Z2, color='b', alpha=0.2) pyplot.show() 

Is there a way to get rid of bloody things so that you have a flat surface? I added an image to show what I mean. enter image description here

+4
source share
1 answer

Try

 ax.plot_surface(X, Y, Z1, color='w', alpha=0.2, linewidth=0) ax.plot_surface(X, Y, Z2, color='b', alpha=0.2, linewidth=0) 

You might want to slightly increase your alpha values, although if you remove the lines, it is too difficult to see parts of the surfaces.

+6
source

All Articles