zoukankan      html  css  js  c++  java
  • 3D 数据

    # View more python tutorials on my Youtube and Youku channel!!!
    
    # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
    # Youku video tutorial: http://i.youku.com/pythontutorial
    
    # 14 - 3d
    """
    Please note, this script is for python3+.
    If you are using python2+, please modify it accordingly.
    Tutorial reference:
    http://www.python-course.eu/matplotlib_multiple_figures.php
    """
    
    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    
    fig = plt.figure()
    ax = Axes3D(fig)
    # X, Y value
    X = np.arange(-4, 4, 0.25)
    Y = np.arange(-4, 4, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X ** 2 + Y ** 2)
    # height value
    Z = np.sin(R)
    
    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap('rainbow'))
    """
    ============= ================================================
            Argument      Description
            ============= ================================================
            *X*, *Y*, *Z* Data values as 2D arrays
            *rstride*     Array row stride (step size), defaults to 10
            *cstride*     Array column stride (step size), defaults to 10
            *color*       Color of the surface patches
            *cmap*        A colormap for the surface patches.
            *facecolors*  Face colors for the individual patches
            *norm*        An instance of Normalize to map values to colors
            *vmin*        Minimum value to map
            *vmax*        Maximum value to map
            *shade*       Whether to shade the facecolors
            ============= ================================================
    """
    
    # I think this is different from plt12_contours
    ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.get_cmap('rainbow'))
    """
    ==========  ================================================
            Argument    Description
            ==========  ================================================
            *X*, *Y*,   Data values as numpy.arrays
            *Z*
            *zdir*      The direction to use: x, y or z (default)
            *offset*    If specified plot a projection of the filled contour
                        on this position in plane normal to zdir
            ==========  ================================================
    """
    
    ax.set_zlim(-2, 2)
    
    plt.show()
    

      

  • 相关阅读:
    结对作业(1)--疫情统计可视化(原型设计)
    软工实践寒假作业(2/2)疫情统计程序
    最长回文
    吉哥系列故事——完美队形II ——Manacher算法
    友情链接
    代码互改——第二次个人编程作业
    汉字编程——第一次个人编程作业
    谈谈自己
    OO第一次博客
    OO第一单元作业总结
  • 原文地址:https://www.cnblogs.com/jianglijian/p/10083088.html
Copyright © 2011-2022 走看看