zoukankan      html  css  js  c++  java
  • motplotlib使用

    # -*- coding: utf-8 -*-
    """
    Spyder Editor
      
    This is a temporary script file.
     """
    
    import numpy as np               #引用numpy库,从新命名它为np(以后用np代替numpy,简洁)
    import matplotlib.pyplot as plt
    import matplotlib
    x = np.linspace(0,6,100)    #在【06】平均分为100个
    print(x)   #输出查看一下x内容
    y = np.cos(2*np.pi*x) * np.exp(-x) + 0.8   #调用np库里的cos函数
    print(y)  #输出Y查看一下内容
    plt.plot(x,y,'k',color='r',linewidth=3,linestyle="-") #color='r'代表红色
    plt.show() #展示绘图

    # -*- coding: utf-8 -*-
    """
    Spyder Editor
    
    This is a temporary script file.
    """
    
    import numpy as np
    import matplotlib.pyplot as plt
    x=np.linspace(0,10,1000)
    y=np.cos(2*np.pi*x)*np.exp(-x)+0.8
    plt.plot(x,y,'k',color='r',label="$exp-decay$",linewidth=3)
    plt.axis([0,6,0,1.8])
    ix=(x>0.8)&(x<3)
    plt.fill_between(x,y,0,where=ix,facecolor='red',alpha=0.25)
    plt.text(0.5*(0.8+3),0.2,r"$int_a^b f(x)mathrm{d}x$",horizontalignment='center')
    plt.legend()
    plt.show()

  • 相关阅读:
    第二次冲刺(二)
    第二次冲刺(一)
    5月30日学习日志
    5月29日学习日志
    5月28日学习日志
    5月27日学习日志
    5月26日学习日志
    粒子群算法-PSO
    花授粉优化算法-python/matlab
    花授粉优化算法
  • 原文地址:https://www.cnblogs.com/lzz807237221/p/10726375.html
Copyright © 2011-2022 走看看