Plotting a 2d Array with mplot3d

前端 未结 4 1839
一整个雨季
一整个雨季 2021-01-31 20:40

I have a 2D numpy array and I want to plot it in 3D. I heard about mplot3d but I cant get to work properly

Here\'s an example of what I want to do. I have an array with

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 20:53

    You can also use oct2py module which is actually an python-octave bridge. Using it you can exploit fucntions of octave, and you can get the thing you need, and it's pretty easy as well.

    check out this documentation : https://www.gnu.org/software/octave/doc/v4.0.1/Three_002dDimensional-Plots.html

    And for sample example:

    from oct2py import octave as oc
    
    tx = ty = oc.linspace (-8, 8, 41)
    [xx, yy] = oc.meshgrid (tx, ty)
    r = oc.sqrt (xx * xx + yy * yy) + oc.eps()
    tz = oc.sin (r) / r
    oc.mesh (tx, ty, tz)
    

    Above is the python code, which is as same as the first example implemented in octave in the above documentation.

提交回复
热议问题