Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting rid of artifacts/grid-lines when plotting 3d surfaces

When plotting surfaces using mpl_toolkits.mplot3d.Axes3D.plot_surface(), lines appear that seem to follow the curve of the surfaces being plotted. For example:

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 any way to get rid of the bloody things so you just have a smooth surface? I've attached an image to show what I mean. enter image description here

like image 245
Chinmay Kanchi Avatar asked Jun 08 '11 17:06

Chinmay Kanchi


1 Answers

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 may want to increase your alpha values a bit, though, if taking away the lines makes parts of the surfaces too hard to see.

like image 136
JAB Avatar answered Oct 17 '22 15:10

JAB