如何在图的中间绘制轴?

如何在图的中间绘制轴?,第1张

如何在图的中间绘制轴?

一种方法是使用刺:

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()

显示



欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5668296.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存