本文介绍了matplotlib plot_trisurf 无边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.htmlthe edges of the triangles are shown.

使用参数edgecolors ="none",边缘仍然可见.

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

我的意思是渲染工件,而不是边缘,仍然可见.

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

推荐答案

在使用 edgecolor ='none' ...(从matplotlib演示中盗取的代码)时为我工作

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

创建:

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

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

这篇关于matplotlib plot_trisurf 无边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:40