matplotlib

matplotlib plot_trisurf without edges


Is it possible to plot_trisurf without showing the edges of the triangles at all? In all the examples the edges of the triangles are shown.

With the argument edgecolors="none" the edges are still visible.

edit: I meant the rendering artifacts, not the edges, are still visible.


Solution

  • Works for me when using edgecolor='none'... (Code stolen from the matplotlib demos)

    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.tri as mtri
    
    # u, v are parameterisation variables
    u = (np.linspace(0, 2.0 * np.pi, endpoint=True, num=50) * np.ones((10, 1))).flatten()
    v = np.repeat(np.linspace(-0.5, 0.5, endpoint=True, num=10), repeats=50).flatten()
    
    # This is the Mobius mapping, taking a u, v pair and returning an x, y, z
    # triple
    x = (1 + 0.5 * v * np.cos(u / 2.0)) * np.cos(u)
    y = (1 + 0.5 * v * np.cos(u / 2.0)) * np.sin(u)
    z = 0.5 * v * np.sin(u / 2.0)
    
    # Triangulate parameter space to determine the triangles
    tri = mtri.Triangulation(u, v)
    
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection='3d')
    ax.plot_trisurf(x,y,z,triangles=tri.triangles, cmap=plt.cm.Spectral, edgecolor='none')
    

    creates:

    enter image description here

    The remaining edge ghosts are rendering artifacts. Are they a problem?