新聞中心
小伙伴們還記不記得,在高考數(shù)學(xué)題后面的大題總會(huì)出現(xiàn)對(duì)數(shù)函數(shù),需要我們畫成對(duì)數(shù)函數(shù)圖才能解答。之前小編向大家介紹對(duì)數(shù)log函數(shù)的表示方法(https://www.py.cn/jishu/jichu/21780.html),其實(shí)一般我們?cè)谑褂脤?duì)數(shù)函數(shù)的時(shí)候,會(huì)和對(duì)數(shù)函數(shù)圖配合使用解決實(shí)際問(wèn)題。那你知不知道在python中也可以畫對(duì)數(shù)函數(shù)圖呢?本文小編就以代碼的形式向大家演示在python中繪制對(duì)數(shù)函數(shù)圖的過(guò)程。話不多說(shuō),直接上代碼。

北塔網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)公司自2013年起到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。
代碼:
import math import matplotlib.pyplot as plt import numpy as np """簡(jiǎn)單log函數(shù)的實(shí)現(xiàn)""" 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()
以上就是用python畫對(duì)數(shù)函數(shù)的代碼,如果有畫對(duì)數(shù)函數(shù)圖需求的小伙伴,可以帶入不同的底數(shù)和指數(shù)使用哦~希望能對(duì)你有所幫助。
當(dāng)前文章:創(chuàng)新互聯(lián)Python教程:python中如何畫對(duì)數(shù)函數(shù)圖?
網(wǎng)頁(yè)網(wǎng)址:http://m.fisionsoft.com.cn/article/dhjseih.html


咨詢
建站咨詢
