1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【Python】Matplotlib画图(二)——根据函数公式画图

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

时间:2021-04-11 06:30:31

相关推荐

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

环境

Python3

Mac os

代码

# coding:utf-8"""Author: roguesirDate: /8/30GitHub: Blog: /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() # 显示画图

输出图片

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。