#題目:分別作 y=logx/log2 , y=logx/log0.5 的函數圖形
#Python 程式碼如下
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
X = np.linspace(0.01, 8, 100)
y1 = np.log(X)/np.log(2)
y2 = np.log(X)/np.log(0.5)
plt.figure(figsize=(8,6),dpi=80)
ax = plt.gca() # gca stands for 'get current axis'
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
plt.plot(X, y1, color="red", linewidth=1.0, linestyle="-", label="$y=logx/log2$")
plt.plot(X, y2, color="green", linewidth=1.0, linestyle="-", label="$y=logx/log0.5$")
plt.legend(loc='upper right')
plt.show()
# 輸出結果如下:
#題目:分別作 y=logx/log2 , y=logx/log0.5 的函數圖形
訂閱:
文章 (Atom)