一种方法是使用刺:
import mathimport numpy as npimport matplotlib.pyplot as pltdef sigmoid(x): a = [] for item in x: a.append(1/(1+math.exp(-item))) return ax = np.arange(-10., 10., 0.2)sig = sigmoid(x)fig = plt.figure()ax = fig.add_subplot(1, 1, 1)# Move left y-axis and bottim x-axis to centre, passing through (0,0)ax.spines['left'].set_position('center')ax.spines['bottom'].set_position('center')# Eliminate upper and right axesax.spines['right'].set_color('none')ax.spines['top'].set_color('none')# Show ticks in the left and lower axes onlyax.xaxis.set_ticks_position('bottom')ax.yaxis.set_ticks_position('left')plt.plot(x,sig)plt.show()
显示:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)