Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbebd7f1

Browse files
kolibril13timhoffm
authored andcommitted
Example for axhline and axvline (#15914)
* Example for sigmoid function with horizontal lines* simplified script and changed title* fixed typo* Fixing heading markup and specifying purpose of plot* remove blank line* added per-file-ignores sigmoid_function.py : E402* Rename example file sigmoid_function.py to axline.py
1 parent59acd5c commitbebd7f1

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
@@ -195,6 +195,7 @@ per-file-ignores =
195195
examples/pyplots/annotation_basic.py: E402
196196
examples/pyplots/annotation_polar.py: E231, E402
197197
examples/pyplots/auto_subplots_adjust.py: E231, E302, E402
198+
examples/pyplots/axline.py: E402
198199
examples/pyplots/boxplot_demo_pyplot.py: E231, E402
199200
examples/pyplots/compound_path_demo.py: E231
200201
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+
importnumpyasnp
12+
importmatplotlib.pyplotasplt
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+
importmatplotlib
38+
matplotlib.pyplot.axhline
39+
matplotlib.pyplot.axvline
40+
matplotlib.axes.Axes.axhline
41+
matplotlib.axes.Axes.axvline

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp