zoukankan      html  css  js  c++  java
  • matplotlib绘制等高线图

     参考自Matplotlib Python 画图教程 (莫烦Python)(12)_演讲•公开课_科技_bilibili_哔哩哔哩 https://www.bilibili.com/video/av16378354/index_10.html#page=12

    """绘制等高线图"""
    
    
    import numpy as np
    import matplotlib.pyplot as plt
    
    
    def calcu_elevation(x1, y1):  # 计算高程
    
        ele = (1-x1/2+x1**5+y1**3)*np.exp(-x1**2-y1**2)
        return ele
    
    
    n = 256
    x = np.linspace(-3, 3, n)
    y = np.linspace(-3, 3, n)
    X, Y = np.meshgrid(x, y)  # 将原始数据变为网格数据
    # 填充等高线的颜色, 8是等高线分为几部分
    plt.contourf(X, Y, calcu_elevation(X, Y), 8, alpha=0.75, cmap=plt.cm.hot)  # 8表示要分几部分等高线
    # 画等高线
    C = plt.contour(X, Y, calcu_elevation(X, Y), 8, colors='black', linewidth=0.5)
    plt.clabel(C, inline=True, fontsize=10)  # 添加文字标签 inlins表示等高线是穿过数字还是不穿过
    
    plt.xticks([])
    plt.yticks([])
    plt.show()

  • 相关阅读:
    053364
    053363
    oracle导出批量表N行记录
    053362
    053361
    053360
    053359
    053358
    053357
    053356
  • 原文地址:https://www.cnblogs.com/laumians-notes/p/8231772.html
Copyright © 2011-2022 走看看