一个神奇的函数
# -*- coding: UTF-8 -*-
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(6,10), dpi=80)
plt.subplot(111)
X = np.linspace(0.01, 1.2, 1000,endpoint=True)
# log()是以无理数e为底的自然对数log=ln;log10()是以10为底的常用对数log10=lg。
# C = np.log2(X)
# C = 3*X*np.log(X)-(2.71828**(-(30/2.71828-30*X)**4))/20
D = 4*X*np.log(X)-(np.exp(-(30/np.exp(1)-30*X)**4))/10
plt.plot(D, X, color="Green", linewidth=2.0, linestyle="-")
C = 3*X*np.log(X)-(np.exp(-(30/np.exp(1)-30*X)**4))/10
plt.plot(C, X, color="blue", linewidth=2.0, linestyle="-")
B = 2*X*np.log(X)-(np.exp(-(30/np.exp(1)-30*X)**4))/20
plt.plot(B, X, color="red", linewidth=2.0, linestyle="-")
t = 0.37
K = 4*t*np.log(t)-(np.exp(-(30/np.exp(1)-30*t)**4))/10
plt.plot([K,0],[t,t], color ='orange', linewidth=1.5, linestyle="--")
plt.scatter([K,],[t,], 50, color ='orange')
plt.annotate(r'${f}({y})={4*y*ln(y)-\frac{1}{20}{*}e^{-(\frac{30}{e}-30*y)^{4}}}$',
xy=(-1.22, 0.6), xycoords='data',
xytext=(-160, 180), textcoords='offset points', fontsize=20,
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))
ax = plt.gca()
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.2))
plt.xlim(-1.8,-0.2)
plt.ylim(0,1)
plt.show()
网页版iPython:
http://ooou6mjma.bkt.clouddn.com/bra4.html