0

这是我想要做的:我有一个表面,我想要一个 3D 绘图和一个数组,我想在表面下方绘制一个垂直平面。曲面与平面应形成T型可视化。该数组包含值,并且我将值的相应 x 和 y 坐标存储在其他 2 个数组中(间距不规则)。

这是我到目前为止一直在尝试的......:

#!/usr/bin/env/python2

import numpy as np
from mayavi import mlab

def test_surf():

    def f(x,y):
        sin, cos = np.sin, np.cos
        #return sin(x + y) + sin(2 * x - y) + cos(3 * x + 4 * y)
        return sin(x) + cos(y)

    x, y = np.mgrid[-7.:7.05:0.1, -5.:5.05:0.05]
    s = mlab.surf(x, y, f)
    return s


def add_2dimage():

    im = np.random.random((15,15))
    #x , y = np.mgrid[0:10:1,0:10:1]
    #src = mlab.pipeline.scalar_field(x,y,im)
    im = im[:, np.newaxis, :]
    src = mlab.pipeline.scalar_field(im)
    image = mlab.pipeline.surface(src)
    return image

if __name__ == "__main__":

    test_surf()
    add_2dimage()
    mlab.show()
4

0 回答 0