Guest User

Untitled

a guest
Jan 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from matplotlib.figure import figaspect
  4.  
  5. f = lambda x: 1 / (1 + np.exp(-x))
  6. xlim = (-3, 3)
  7. x = np.linspace(xlim[0], xlim[1], 100)
  8.  
  9. fig = plt.figure(figsize=figaspect(1))
  10. ax = fig.gca()
  11. ax.plot(x, f(x), color='b')
  12. ax.hlines((0, 1), xlim[0], xlim[1], color='k', alpha=0.3, linestyle='dashed')
  13. ylim = ax.get_ylim()
  14. ax.vlines(0, ylim[0], ylim[1], color='k', alpha=0.3, linestyle='dashed')
  15. ax.set(xlim=xlim, ylim=ylim, xticks=(0, ), yticks=(0, 1), xlabel='$x$')
  16. ax.get_yaxis().get_label().set(
  17. text=r'$\frac{1}{1+e^{-x}}$',
  18. size=15,
  19. rotation=0,
  20. horizontalalignment='right')
  21. plt.show()
Add Comment
Please, Sign In to add comment