Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib.figure import figaspect
- f = lambda x: 1 / (1 + np.exp(-x))
- xlim = (-3, 3)
- x = np.linspace(xlim[0], xlim[1], 100)
- fig = plt.figure(figsize=figaspect(1))
- ax = fig.gca()
- ax.plot(x, f(x), color='b')
- ax.hlines((0, 1), xlim[0], xlim[1], color='k', alpha=0.3, linestyle='dashed')
- ylim = ax.get_ylim()
- ax.vlines(0, ylim[0], ylim[1], color='k', alpha=0.3, linestyle='dashed')
- ax.set(xlim=xlim, ylim=ylim, xticks=(0, ), yticks=(0, 1), xlabel='$x$')
- ax.get_yaxis().get_label().set(
- text=r'$\frac{1}{1+e^{-x}}$',
- size=15,
- rotation=0,
- horizontalalignment='right')
- plt.show()
Add Comment
Please, Sign In to add comment