使用python来画各种log的对数函数

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)
    print(type(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()
简单log对数函数的Python实现

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
猜你喜欢
  • 2018-01-19
  • 2021-10-16
  • 2022-02-08
  • 2022-12-23
  • 2021-05-19
  • 2021-11-26
相关资源
相似解决方案