Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30debde

Browse files
authored
Merge pull request #15954 from meeseeksmachine/auto-backport-of-pr-15914-on-v3.2.x
Backport PR #15914 on branch v3.2.x (Example for sigmoid function with horizontal lines)
2 parents fe93c18 + 9c3a78e commit 30debde

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ per-file-ignores =
165165
examples/pyplots/annotation_basic.py: E402
166166
examples/pyplots/annotation_polar.py: E231, E402
167167
examples/pyplots/auto_subplots_adjust.py: E231, E302, E402
168+
examples/pyplots/axline.py: E402
168169
examples/pyplots/boxplot_demo_pyplot.py: E231, E402
169170
examples/pyplots/compound_path_demo.py: E231
170171
examples/pyplots/dollar_ticks.py: E402

examples/pyplots/axline.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

Comments
 (0)