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

Appearance settings

Commit c7e286e

Browse filesBrowse files
authored
Merge pull request #29622 from timhoffm/doc-move-axline
DOC: Move "Infinite lines" example from section "pyplot" to "Lines, bars and markers
2 parents ac75741 + ffcb1e0 commit c7e286e
Copy full SHA for c7e286e

File tree

1 file changed

+17
-13
lines changed
Filter options
  • galleries/examples/lines_bars_and_markers

1 file changed

+17
-13
lines changed

‎galleries/examples/pyplots/axline.py renamed to ‎galleries/examples/lines_bars_and_markers/axline.py

Copy file name to clipboardExpand all lines: galleries/examples/lines_bars_and_markers/axline.py
+17-13Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
sigmoid function.
1010
1111
`~.axes.Axes.axline` draws infinite straight lines in arbitrary directions.
12+
13+
.. redirect-from:: /gallery/pyplot/axline
1214
"""
1315

1416
import matplotlib.pyplot as plt
@@ -17,28 +19,28 @@
1719
t = np.linspace(-10, 10, 100)
1820
sig = 1 / (1 + np.exp(-t))
1921

20-
plt.axhline(y=0, color="black", linestyle="--")
21-
plt.axhline(y=0.5, color="black", linestyle=":")
22-
plt.axhline(y=1.0, color="black", linestyle="--")
23-
plt.axvline(color="grey")
24-
plt.axline((0, 0.5), slope=0.25, color="black", linestyle=(0, (5, 5)))
25-
plt.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
26-
plt.xlim(-10, 10)
27-
plt.xlabel("t")
28-
plt.legend(fontsize=14)
22+
fig, ax = plt.subplots()
23+
ax.axhline(y=0, color="black", linestyle="--")
24+
ax.axhline(y=0.5, color="black", linestyle=":")
25+
ax.axhline(y=1.0, color="black", linestyle="--")
26+
ax.axvline(color="grey")
27+
ax.axline((0, 0.5), slope=0.25, color="black", linestyle=(0, (5, 5)))
28+
ax.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
29+
ax.set(xlim=(-10, 10), xlabel="t")
30+
ax.legend(fontsize=14)
2931
plt.show()
3032

3133
# %%
32-
# `~.axes.Axes.axline` can also be used with a ``transform`` parameter, which
34+
# `~.axes.Axes.axline` can also be used with a *transform* parameter, which
3335
# applies to the point, but not to the slope. This can be useful for drawing
3436
# diagonal grid lines with a fixed slope, which stay in place when the
3537
# plot limits are moved.
3638

39+
fig, ax = plt.subplots()
3740
for pos in np.linspace(-2, 1, 10):
38-
plt.axline((pos, 0), slope=0.5, color='k', transform=plt.gca().transAxes)
41+
ax.axline((pos, 0), slope=0.5, color='k', transform=ax.transAxes)
3942

40-
plt.ylim([0, 1])
41-
plt.xlim([0, 1])
43+
ax.set(xlim=(0, 1), ylim=(0, 1))
4244
plt.show()
4345

4446
# %%
@@ -57,3 +59,5 @@
5759
#
5860
# `~.Axes.axhspan`, `~.Axes.axvspan` draw rectangles that span the Axes in one
5961
# direction and are bounded in the other direction.
62+
#
63+
# .. tags:: component: annotation

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.