|
| 1 | +""" |
| 2 | +====================================== |
| 3 | +Infinite horizontal and vertical lines |
| 4 | +====================================== |
| 5 | +
|
| 6 | +`~.axes.Axes.axvline` and `~.axes.Axes.axhline` draw infinite vertical / |
| 7 | +horizontal lines, at given *x* / *y* positions. They are usually used to mark |
| 8 | +special data values, e.g. in this example the center and limit values of the |
| 9 | +sigmoid function. |
| 10 | +""" |
| 11 | +import numpy as np |
| 12 | +import matplotlib.pyplot as plt |
| 13 | + |
| 14 | +t = np.linspace(-10, 10, 100) |
| 15 | +sig = 1 / (1 + np.exp(-t)) |
| 16 | + |
| 17 | +plt.axhline(y=0, color="black", linestyle="--") |
| 18 | +plt.axhline(y=0.5, color="black", linestyle=":") |
| 19 | +plt.axhline(y=1.0, color="black", linestyle="--") |
| 20 | +plt.axvline(color="grey") |
| 21 | +plt.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$") |
| 22 | +plt.xlim(-10, 10) |
| 23 | +plt.xlabel("t") |
| 24 | +plt.legend(fontsize=14) |
| 25 | +plt.show() |
| 26 | + |
| 27 | +############################################################################# |
| 28 | +# |
| 29 | +# ------------ |
| 30 | +# |
| 31 | +# References |
| 32 | +# """""""""" |
| 33 | +# |
| 34 | +# The use of the following functions, methods, classes and modules is shown |
| 35 | +# in this example: |
| 36 | + |
| 37 | +import matplotlib |
| 38 | +matplotlib.pyplot.axhline |
| 39 | +matplotlib.pyplot.axvline |
| 40 | +matplotlib.axes.Axes.axhline |
| 41 | +matplotlib.axes.Axes.axvline |
0 commit comments