zoukankan      html  css  js  c++  java
  • 科学计算三维可视化---Mlab基础(改变物体的外观颜色)

    import numpy as np
    from mayavi import mlab
    
    #建立数据
    x,y = np.mgrid[-10:10:200j,-10:10:200j]
    z = 100*np.sin(x*y)/(x*y)
    #对数据进行可视化
    mlab.figure(bgcolor=(1,1,1))
    surf = mlab.surf(z,colormap="cool")  #cool使用冷色系
    #更新视图并显示出来
    mlab.show()
    >>> x,y = np.mgrid[-10:10:200j,-10:10:200j]
    >>> z = 100*np.sin(x*y)/(x*y)  #是一个二维数据
    >>> z
    array([[-0.50636564, -1.00954046, -0.57671118, ..., -0.57671118,
            -1.00954046, -0.50636564],
           [-1.00954046, -0.58512546,  0.38643354, ...,  0.38643354,
            -0.58512546, -1.00954046],
           [-0.57671118,  0.38643354,  1.02032807, ...,  1.02032807,
             0.38643354, -0.57671118],
           ...,
           [-0.57671118,  0.38643354,  1.02032807, ...,  1.02032807,
             0.38643354, -0.57671118],
           [-1.00954046, -0.58512546,  0.38643354, ...,  0.38643354,
            -0.58512546, -1.00954046],
           [-0.50636564, -1.00954046, -0.57671118, ..., -0.57671118,
            -1.00954046, -0.50636564]])
    >>>

    import numpy as np
    from mayavi import mlab
    
    #建立数据
    x,y = np.mgrid[-10:10:200j,-10:10:200j]
    z = 100*np.sin(x*y)/(x*y)
    #对数据进行可视化
    mlab.figure(bgcolor=(1,1,1))
    surf = mlab.surf(z,colormap="cool")
    #访问surf对象的LUT
    #LUT是一个255*4的数组,列向量表示RGBA,每个值的范围从0-255
    lut = surf.module_manager.scalar_lut_manager.lut.table.to_array()
    #增加透明度,修改alpha通道
    lut[:,-1] = np.linspace(0,255,256)  #修改列向量中A通道
    surf.module_manager.scalar_lut_manager.lut.table = lut
    
    #更新视图并显示出来
    mlab.show()

  • 相关阅读:
    Android新手引导库推荐
    windbg 常调用指令
    通过Hook NtOpenProcess 函数实现反调试
    PE文件
    消息机制
    软件调试
    异常(2) --- 编译器对于SEH异常的拓展
    异常(1)
    等待对象
    进程与线程
  • 原文地址:https://www.cnblogs.com/ssyfj/p/9304331.html
Copyright © 2011-2022 走看看