【问题标题】:Mayavi doesn't draw linesMayavi 不画线
【发布时间】:2017-02-21 14:41:58
【问题描述】:

我想用 4 个节点和 3 个边绘制非常简单的图形:

    from numpy import array, vstack
    from mayavi import mlab

    mlab.figure(1, bgcolor=(1, 0.9, 1))
    mlab.clf()
    x = array([0, 3, 2, 3])
    y = array([0, 4, 5, 1])
    z = array([0, 0, 1, 1])
    color = array([0.1, 0.3, 0.5, 0.7])

    pts = mlab.points3d(x, y, z,
                        color,
                        scale_factor=1,
                        scale_mode='none',
                        colormap='Blues',
                        resolution=20)

    edges = vstack([[0, 1], [0, 2], [0, 3]])
    pts.mlab_source.dataset.lines = edges
    tube = mlab.pipeline.tube(pts, tube_radius=0.1, tube_sides=7)
    mlab.pipeline.surface(tube, color=(0.8, 0.8, 0.8))
    mlab.show()

它返回:

为什么缺少边缘?

【问题讨论】:

    标签: mayavi graph-visualization


    【解决方案1】:

    Mayavi 中有一个关于此的错误。它与与 VTK 的不同步更改有关,因此有点难以确定。 Mayavi的GitHub上有讨论https://github.com/enthought/mayavi/issues/388

    该错误还出现在 Mayavi 提供的 protein.py 示例中,通过添加该错误已修复

    pts.mlab_source.update()
    

    设置线后。在https://github.com/enthought/mayavi/commit/afb17fceafe787c8260ca7a37fbb3b8c2fbfd36c的示例中已在线修复

    虽然使用修复对我不起作用,但您可以尝试。

    【讨论】:

    • 谢谢,在我的情况下,它迫使管子出现。
    猜你喜欢
    • 2012-05-19
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    相关资源
    最近更新 更多