matplotlib plot_trisurf没有边缘

时间:2014-08-24 21:07:16

标签: matplotlib

是否可以在不显示三角形边缘的情况下plot_trisurf? 在所有的例子中: http://matplotlib.org/dev/examples/mplot3d/trisurf3d_demo2.html 显示三角形的边缘。

使用参数edgecolors =“none”,边缘仍然可见。

编辑:我的意思是渲染工件,而不是边缘,仍然是可见的。

3 个答案:

答案 0 :(得分:5)

使用edgecolor='none'时可以使用我...(从matplotlib演示中窃取的代码)

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')

创建:

enter image description here

剩余的边缘重影是渲染伪像。他们有问题吗?

答案 1 :(得分:1)

您可以将linewidth参数传递给plot_trisurf以使边消失:

ax.plot_trisurf(x,y,z,triangles=tri.triangles, cmap=plt.cm.Spectral, linewidth=0, antialiased=False)

答案 2 :(得分:1)

对我来说,enter image description hereDrV的组合正在指定

  1. edgecolor='none'
  2. a linewidth=0
  3. 同时设置antialiased=False