Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ per-file-ignores =
examples/pyplots/annotation_basic.py: E402
examples/pyplots/annotation_polar.py: E231, E402
examples/pyplots/auto_subplots_adjust.py: E231, E302, E402
examples/pyplots/axline.py: E402
examples/pyplots/boxplot_demo_pyplot.py: E231, E402
examples/pyplots/compound_path_demo.py: E231
examples/pyplots/dollar_ticks.py: E402
Expand Down
41 changes: 41 additions & 0 deletions examples/pyplots/axline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
======================================
Infinite horizontal and vertical lines
======================================

`~.axes.Axes.axvline` and `~.axes.Axes.axhline` draw infinite vertical /
horizontal lines, at given *x* / *y* positions. They are usually used to mark
special data values, e.g. in this example the center and limit values of the
sigmoid function.
"""
import numpy as np
import matplotlib.pyplot as plt

t = np.linspace(-10, 10, 100)
sig = 1 / (1 + np.exp(-t))

plt.axhline(y=0, color="black", linestyle="--")
plt.axhline(y=0.5, color="black", linestyle=":")
plt.axhline(y=1.0, color="black", linestyle="--")
plt.axvline(color="grey")
plt.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
plt.xlim(-10, 10)
plt.xlabel("t")
plt.legend(fontsize=14)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.pyplot.axhline
matplotlib.pyplot.axvline
matplotlib.axes.Axes.axhline
matplotlib.axes.Axes.axvline