【Python】Matplotlib画图(二)——根据函数公式画图

来源:互联网 发布:淘宝旺铺智能版好用吗 编辑:程序博客网 时间:2024/06/05 18:03

环境

Python3

Mac os

代码

# coding:utf-8"""Author: roguesirDate: 2017/8/30GitHub: https://roguesir.github.comBlog: http://blog.csdn.net/roguesir"""import numpy as npimport matplotlib.pyplot as plth0 = [0.4,.6,.8] # h0取值lambda0 = [0.03,0.05,0.07] # λ取值plt.figure(figsize=(6,4)) # 设置图片大小x = np.linspace(0, 50, 50) # 在[0,50)中取50个点for i in lambda0:for h in h0:plt.plot(x, 11+(20*np.exp(-i*x)-h*x)/2,label='lambda='+str(i)+' h='+str(h))# plt.plot(x,y,图例内容)plt.legend() # 显示图例plt.show() # 显示画图

输出图片


原创粉丝点击