Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib plot_trisurf without edges

Tags:

matplotlib

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.

like image 819
pstekl Avatar asked Oct 28 '25 11:10

pstekl


2 Answers

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?

like image 68
DrV Avatar answered Oct 31 '25 12:10

DrV


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.
like image 35
Woltan Avatar answered Oct 31 '25 11:10

Woltan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!