代码:
import math
import matplotlib.pyplot as plt
import numpy as np
"""简单log函数的实现"""
if __name__ == '__main__':
x = np.arange(0.05,3,0.05)
print(x)
y1 = [math.log(a ,1.5) for a in x]
plt.plot(x,y1,linewidth=2,color="#007500",label='log1.5(x)')
plt.plot([1,1],[y1[0],y1[-1]],"r--",linewidth=2)
y2 = [math.log(a, 2)for a in x]
plt.plot(x, y2, linewidth=2, color="#9F35FF", label="log2(x)")
y3 = [math.log(a, 3) for a in x]
plt.plot(x, y3, linewidth=2, color="#F75000", label="log3(x)")
plt.legend(loc="lower right")
plt.grid(True)
plt.show()
声明:本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果用户发布的作品侵犯了您的权利,请联系管理员:wupeng@hqwx.com
环球青藤
官方QQ群扫描上方二维码或点击一键加群,免费领取大礼包,加群暗号:青藤。 一键加群