zoukankan      html  css  js  c++  java
  • matplotlib.pyplot.contour 简单等高线绘制

    contour(X, Y, Z)

    X,Y是与Z形状相同的二维数组,可以通过 numpy.meshgrid()创建。

    numpy.meshgrid()----从坐标向量返回坐标矩阵

    生成的x,y坐标矩阵,组合形成网格点
    a = np.array([1,2,3])          #a.shape  (3,)
    b = np.array([11,22,33,44])    #b.shape  (4,)
    x,y = np.meshgrid(a,b)
    
    x                              #x.shape(4,3)
    
    array([[1, 2, 3],
           [1, 2, 3],
           [1, 2, 3],
           [1, 2, 3] ])
    
    y                             #y.shape(4,3)
    
    array([[11, 11, 11],
           [22, 22, 22],
           [33, 33, 33],
           [44, 44, 44]])        

     1)contour()

    a = np.array([1,2,3])
    z = np.array([[0,1,1],[1,0,1],[1,1,0]])
    x,y = np.meshgrid(a,a)
    plt.contour(x,y,z,3)          #数字3是等高线的数量

     

    2)contourf() 返回填充等高线图,其他输入输出和contour()没有区别

    a = np.array([1,2,3])
    z = np.array([[0,1,1],[1,0,1],[1,1,0]])
    x,y = np.meshgrid(a,a)
    plt.contourf(x,y,z,3)         #contourf() 

  • 相关阅读:
    CentOS VPS
    Make 命令教程
    Nginx 学习
    字体对齐问题
    postman curl
    linux命令
    服务器
    操作系统
    nginx-1.15遇到无法加载php文件报404的问题
    thinkphp6.0框架下载与安装
  • 原文地址:https://www.cnblogs.com/tongtong123/p/10633574.html
Copyright © 2011-2022 走看看