Numpy meshgrid in 3D

前端 未结 7 1186
暖寄归人
暖寄归人 2020-11-27 15:45

Numpy\'s meshgrid is very useful for converting two vectors to a coordinate grid. What is the easiest way to extend this to three dimensions? So given three vectors x, y, an

7条回答
  •  無奈伤痛
    2020-11-27 16:07

    You can achieve that by changing the order:

    import numpy as np
    xx = np.array([1,2,3,4])
    yy = np.array([5,6,7])
    zz = np.array([9,10])
    y, z, x = np.meshgrid(yy, zz, xx)
    

提交回复
热议问题