我跟着http://docs.enthought.com/mayavi/mayavi/auto/example_plotting_many_lines.html在3D中繪製多個點對點線條。 它的工作原理,但我需要根據一些標量值爲每一行着色。在Mayavi中繪製具有特定線條顏色的多條線
如何在每行的基礎上分配這樣的標量值?
我跟着http://docs.enthought.com/mayavi/mayavi/auto/example_plotting_many_lines.html在3D中繪製多個點對點線條。 它的工作原理,但我需要根據一些標量值爲每一行着色。在Mayavi中繪製具有特定線條顏色的多條線
如何在每行的基礎上分配這樣的標量值?
您鏈接的教程確實使用標量來指定線條顏色(使用「重音」貼圖)。當撥打mlab.pipeline.scalar_scatter(x,y,z,s)
時,標量進入s
。
你的意思是要問更多?
下面是包括複製一個DUP每一個點,每出現在一個邊緣的時間解決方法:
def colorize_edges(points, edge_indices, edge_colors):
assert points.ndim == 2
assert points.shape[1] == 3
assert edge_indices.ndim == 2
n_edges = edge_indices.shape[0]
assert edge_indices.shape[1] == 2
edge_indices = edge_indices.astype(int)
assert edge_colors.ndim == 1
assert edge_colors.shape[0] == n_edges
x, y, z = points[:, 0], points[:, 1], points[:, 2]
i, j = edge_indices[:, 0], edge_indices[:, 1]
x = np.hstack([x[i], x[j]])
y = np.hstack([y[i], y[j]])
z = np.hstack([z[i], z[j]])
c = np.hstack([c, c])
src = mlab.pipeline.scalar_scatter(x, y, z, c)
connections = np.vstack([i, j+n_edges]).T
src.mlab_source.dataset.lines = connections
surf = mlab.pipeline.surface(src, line_width=1.0)
mlab.show()
這不回答@ Duga-3遠程警戒雷達的問題;我不知道他爲什麼接受它。在這個例子中,你誤解了怎麼回事:'scalar_scatter(x,y,z,s)'給這些*點賦予唯一的顏色。*當你添加行時('src.mlab_source.dataset.lines = connections') ,mayavi將線顏色渲染爲兩點顏色之間的線性插值。 – BrianTheLion