Numpy meshgrid in 3D

前端 未结 7 1150
暖寄归人
暖寄归人 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:30

    Instead of writing a new function, numpy.ix_ should do what you want.

    Here is an example from the documentation:

    >>> ixgrid = np.ix_([0,1], [2,4])
    >>> ixgrid
    (array([[0],
       [1]]), array([[2, 4]]))
    >>> ixgrid[0].shape, ixgrid[1].shape
    ((2, 1), (1, 2))'
    
    0 讨论(0)
提交回复
热议问题