繪制log()函數圖像,並在圖上標注選定的兩個點


繪制log()函數圖像,並在圖上標注選定的兩個點

import math
import matplotlib.pyplot as plt

if __name__ == '__main__':
    x = [float(i)/200.0 for i in range(1,400)]
    y = [math.log(i) for i in x]
    plt.plot(x,y,'r-',linewidth=3, label= 'log Curve')
    a = [x[30],x[205]]
    b = [y[30],y[205]]
    plt.plot(a,b,'g-',linewidth=2)
    plt.plot(a,b,'b*',markersize=15,alpha=0.75)
    plt.legend(loc='upper left')
    plt.grid(True)
    plt.xlabel('x')
    plt.ylabel('log(x)')
    plt.show()

運行結果如下所示:
在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM