3

Is it possible to plot_trisurf without showing the edges of the triangles at all? In all the examples: http://matplotlib.org/dev/examples/mplot3d/trisurf3d_demo2.html 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.

pstekl
  • 33
  • 1
  • 5

3 Answers3

6

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?

DrV
  • 22,637
  • 7
  • 60
  • 72
  • 1
    Is there a way to remove the rendering artifacts? – pstekl Aug 25 '14 at 10:42
  • Yes, there is. You will have to give each triangle an edge color which is the same as the fill color of the triangle. – DrV Aug 25 '14 at 10:48
  • @DrV How exactly does one go about setting the triangle edge colors? I am having a similar problem and posted a question [here](https://stackoverflow.com/questions/26727277/setting-edgecolor-to-match-facecolor-in-trisurf). – Jonathan A. Gross Nov 05 '14 at 16:45
6

For me a combination of DrV and AnandJ is working with specifying

  1. an edgecolor='none',
  2. a linewidth=0 and
  3. setting antialiased=False also.
Woltan
  • 13,723
  • 15
  • 78
  • 104
1

You can pass linewidth argument to plot_trisurf to make edges disappear:

ax.plot_trisurf(x,y,z,triangles=tri.triangles, cmap=plt.cm.Spectral, linewidth=0, antialiased=False)
Woltan
  • 13,723
  • 15
  • 78
  • 104
AnandJ
  • 346
  • 4
  • 15